Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- result = False # condition variable that keeps us inside the while loop
- while not result: # while condition variable is not True
- num = random.randrange(1000, 9999) # generating a random number between given numbers
- user_answer = input("Do you think", num, "is divisible by 13? yes or no?") # getting input from the user in yes or no (Lowercase yes is necessary)
- if user_answer == "yes" and num % 13 == 0: # check if response is yes and number is also divisible by 13
- result = False # if yes, set the condition variable from while loop to True
- else:
- print("Incorrect answer, lets try that again :)") # if answer is wrong we don't update the condition variable and program stays inside the loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement