Nov-25-2017, 04:18 PM
Pages: 1 2
Nov-25-2017, 04:25 PM
Ops, you are right:
Wrong:
Wrong:
if p.lower == "no" or "n":Right:
if p.lower() == "no" or p.lower() == "n":
Nov-25-2017, 04:33 PM
# This works! import random from random import randint n = ['no', 'n', 'No', 'N', 'NO'] y = ['yes', 'y', 'Yes', 'Y', 'YES'] x = random.randint(1,100) print("Guess a number between 1 and 100.") active = True while active: guess = int(input("")) if guess == x: print("Congratulations! Would you like to play again?") play_again = input("") if play_again in n: print("Thanks for playing!") active = False elif play_again in y: print("Guess a number between 1 and 100.") elif guess < 1 or guess > 100: print("You have to choose a number between 1 and 100.") print("Please guess again.") elif guess < x: print("Please choose a higher number.") elif guess > x: print("Please choose a smaller number.")
Nov-25-2017, 04:38 PM
Good work.
Pages: 1 2