#this program uses an 'if' statements # Declaring Variables import random from random import randint ai_guess = random.randint(0,100) print "I want you to guess a number between 0 and 100..." print "I will tell you wheather it is higher or lower" total_count = 0 t_ans = False cont = True while cont == True: while t_ans == False: x = int(raw_input()) if total_count < 5: if x > ai_guess: print "Too High ", str(x) total_count = total_count + 1 elif x < ai_guess: print "Too Low ", str(x) total_count = total_count + 1 else: print "CORRECT YOU WIN!" t_ans = True break elif total_count == 5: print "you have failed" print "my number was: " , ai_guess break print "Do you wish to play again" cont_ui = raw_input() if cont_ui = "yes","Yes","y","Y": else: cont = False
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question