import random import sys enter = "Please Press Enter to continue..." print "Heloo welcome to a guessing Game!" print "Please Guess A Number between 1 - 100!" computernum = random.randint (1,100) Guess1 = raw_input ("My First Guess Is:") if Guess1 == computernum: print "You Win!" raw_input (enter) sys.exit (0) else: print "Sorry, try again!" Guess2 = raw_input ("My Second guess is: ") if Guess2 == computernum: print "WOW, CONGRATULATIONS! YOU WIN" raw_input (enter) sys.exit (0) else: print "Sorry, one mmore try!" print "YOU HAVE ONE GUESS REMAINING!" Guess3 = raw_input ("My Final Guess Is:") if Guess3 == computernum: print "CONGRATULATIONS! WINNEr, WINNER,!" raw_input(enter) sys.exit (0) else: print "Sorry, you lose the game!" computernum = str(computernum) print "The Computer number was: "+computernum raw_input (enter) sys.exit (0)
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