Created
May 7, 2021 06:10
-
-
Save conf8o/37f4c73e37f12781461896adb7725edc 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
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) | |
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
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