Created
July 31, 2020 02:34
-
-
Save cybnz/f1b01ae000327e4bde2952a1e134b76e to your computer and use it in GitHub Desktop.
Checks for blanks and numbers
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
# Get's recipe and checks it is not blank | |
# Not Blank Function goes here | |
def not_blank(question): | |
error = "Your recipe name has numbers in it." | |
valid = False | |
while not valid: | |
response = input(question) | |
has_errors = "" | |
# look at each character in string and if it's a number, complain | |
for letter in response: | |
if letter.isdigit() == True: | |
has_errors = "yes" | |
break | |
if response == "": | |
continue | |
elif has_errors != "": | |
print(error) | |
continue | |
else: | |
return response | |
# Main Routine goes here | |
recipe_name = not_blank("What is the recipe name? ") | |
print("You are making {}".format(recipe_name)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment