Created
June 27, 2021 21:38
-
-
Save Mathsmaniac/4b273b856975638b4e6db181013fdc25 to your computer and use it in GitHub Desktop.
This function gets an input, and if it is a whole number between 1 and 10, it puts the value inuser_balance
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
""" | |
Component 1 of Lucky Unicorn | |
This function gets an input, and if it is a whole number between 1 and 10, it | |
puts the value in user_balance | |
Otherwise, it raises errors and tells the user that a invalid input is entered | |
until a valid input is entered. | |
Written by Nathan Smith | |
28/06/21 | |
""" | |
def check(): | |
print('How much money would you like to play with?') | |
while True: | |
user_balance = input('Please enter a whole number from 1-10: ') | |
try: | |
user_balance = int(user_balance) | |
except ValueError: | |
pass | |
else: | |
if 0 < user_balance < 11: | |
break | |
else: | |
pass | |
check() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment