Skip to content

Instantly share code, notes, and snippets.

@cybnz
Created July 31, 2020 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cybnz/f1b01ae000327e4bde2952a1e134b76e to your computer and use it in GitHub Desktop.
Save cybnz/f1b01ae000327e4bde2952a1e134b76e to your computer and use it in GitHub Desktop.
Checks for blanks and numbers
# 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