Bottom Page

• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 I don't know if it's my error or Python error SkitzGerald Programmer named Tim Posts: 7 Threads: 1 Joined: Nov 2017 Reputation: 0 Likes received: 0 #11 Nov-25-2017, 04:18 PM It's doesn't end the loop when I type no or n though after being asked if I'd like to play again heiner55 Verb Conjugator Posts: 606 Threads: 3 Joined: Nov 2016 Reputation: 29 Likes received: 30 #12 Nov-25-2017, 04:25 PM (This post was last modified: Nov-25-2017, 04:25 PM by heiner55. Edited 2 times in total.) Ops, you are right: Wrong: ```if p.lower == "no" or "n": ```Right: `if p.lower() == "no"  or  p.lower() == "n":` SkitzGerald Programmer named Tim Posts: 7 Threads: 1 Joined: Nov 2017 Reputation: 0 Likes received: 0 #13 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.")``` heiner55 Verb Conjugator Posts: 606 Threads: 3 Joined: Nov 2016 Reputation: 29 Likes received: 30 #14 Nov-25-2017, 04:38 PM (This post was last modified: Nov-25-2017, 04:38 PM by heiner55. Edited 1 time in total.) Good work. « Next Oldest | Next Newest »

Top Page

 Possibly Related Threads... Thread Author Replies Views Last Post Python Code error Riteshfrancis 2 130 May-21-2020, 06:37 AM Last Post: Riteshfrancis python error gfredrickson 2 142 May-10-2020, 09:37 AM Last Post: pyzyx3qwerty Mysql-Python Connectivity Error aryamanurs 2 163 Apr-29-2020, 02:21 PM Last Post: aryamanurs Python: Call function with variabele? Ending in error. efclem 5 166 Apr-22-2020, 02:35 PM Last Post: buran python-resize-image unicode decode error Pedroski55 3 219 Apr-21-2020, 10:56 AM Last Post: Pedroski55 appear fatal error popup for Python 2.7, what to do to Not appear again...? lsepolis123 1 258 Mar-23-2020, 10:44 PM Last Post: lsepolis123 Python 3.7, Windows 7, Syntax Error hughdent 1 256 Mar-23-2020, 10:09 AM Last Post: buran Error in Python3.6:free() Corrupted unsorted chunks error sameer_k 2 270 Mar-18-2020, 09:37 AM Last Post: sameer_k Simple python code error cls0724 5 398 Mar-12-2020, 07:45 PM Last Post: stullis Python Type error! SamAnw 4 306 Feb-14-2020, 03:46 PM Last Post: buran

Forum Jump:

Users browsing this thread: 1 Guest(s)