Skip to content

Instantly share code, notes, and snippets.

@conf8o
Created May 7, 2021 06:10
Show Gist options
  • Save conf8o/37f4c73e37f12781461896adb7725edc to your computer and use it in GitHub Desktop.
Save conf8o/37f4c73e37f12781461896adb7725edc to your computer and use it in GitHub Desktop.
ユーザ入力ループ
def input_loop(question, quit):
while not quit(ans := input(question)):
yield ans
for ans in input_loop("Yo? >>", lambda x: x == "quit"):
print("Your input: ", ans)
Yo? >>Yes
Your input: Yes
Yo? >>No
Your input: No
Yo? >>quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment