Skip to content

Instantly share code, notes, and snippets.

@gitaficionado
Created March 11, 2021 16:36
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 gitaficionado/7c023d20bc17350c3cbdc02c7fc8f9e2 to your computer and use it in GitHub Desktop.
Save gitaficionado/7c023d20bc17350c3cbdc02c7fc8f9e2 to your computer and use it in GitHub Desktop.
Prompt the user for a number from 1 to 100. Using a while loop, if they entered an invalid number, tell them the number entered is invalid and then prompt them again for a number from 1 to 100. If they enter a valid number - thank them for their input.
'''
1. Prompt the user for a number from 1 to 100. Using a while loop, if they entered an invalid number, tell them the number entered is invalid and then prompt them again for a number from 1 to 100. If they enter a valid number - thank them for their input.
Prompt the user for a number from 1 to 100
While that number is less than 1 or that number is more than 100
Output that they entered an invalid number
Prompt them again for a number from 1 to 100
Output to the user, thanking them for their input
'''
# Loop Problem 1
_______ = int(input("Please enter a number from 1 - 100: "))
while _______ < 1 or ________ > 100:
print("You entered an invalid number.")
_________ = int(input("Please enter a number from 1 - 100: "))
print("Thank you for your input.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment