Created
August 27, 2019 06:02
-
-
Save kkismd/2289ac59bb3a1cacffa366fa5dbef8cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List | |
def parseInt(input: str) -> List[int]: | |
try: | |
return [int(input)] | |
except ValueError: | |
return [] | |
def findUser(code: int) -> List[dict]: | |
users = { | |
2012: {"id": 1, "code": 2012, "name": "yuzu"}, | |
3308: {"id": 2, "code": 3308, "name": "yui"} | |
} | |
user = users.get(code) | |
if user: | |
return [user] | |
else: | |
return [] | |
def findItem(userId: int) -> List[dict]: | |
items = { | |
1: {"userId": 1, "name": "keyboard"} | |
} | |
item = items.get(userId) | |
if item: | |
return [item] | |
else: | |
return [] | |
keybord = [item["name"] | |
for code in parseInt("2012") | |
for user in findUser(code) | |
for item in findItem(user["id"])] | |
print(keybord) # => ['keyboard'] | |
what = [item["name"] | |
for code in parseInt("WXYZ") # <- 失敗する | |
for user in findUser(code) | |
for item in findItem(user["id"])] | |
print(what) # => [] | |
guitor = [item["name"] | |
for code in parseInt("3308") | |
for user in findUser(code) | |
for item in findItem(user["id"])] # <- 失敗する | |
print(guitor) # => [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment