I don't know if it's my error or Python error - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: I don't know if it's my error or Python error (/thread-6490.html) Pages:
1
2
|
RE: I don't know if it's my error or Python error - SkitzGerald - Nov-25-2017 It's doesn't end the loop when I type no or n though after being asked if I'd like to play again RE: I don't know if it's my error or Python error - heiner55 - Nov-25-2017 Ops, you are right: Wrong: if p.lower == "no" or "n":Right: if p.lower() == "no" or p.lower() == "n": RE: I don't know if it's my error or Python error - SkitzGerald - Nov-25-2017 # 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.") RE: I don't know if it's my error or Python error - heiner55 - Nov-25-2017 Good work. |