#Importing random and time compatability import random import time #Setting initial values count = 1 theNumber = random.randint(0,1000) #Opening statements print("I'm thinking of a number between 1 and 1000. ") time.sleep(1) print("I want you to guess the number I'm thinking of. ") time.sleep(1) print("Go ahead, guess! ") #Inital guess usrNumber = input("Guess: ") #Guessing Loop while int(usrNumber) != theNumber : #Easter Egg if int(usrNumber) == 420 : print("\nHaha! 420 blaze it motha fucka!!! \nSmoke weed every day!!! \n") time.sleep(1) if int(usrNumber) > theNumber : print("Wrong! My number is lower. ") elif int(usrNumber) < theNumber : print("Nope! The number I'm thinking of is higher! ") else: print("I'm sorry. You're guess is invalid. Please guess again. ") count = count + 1 time.sleep(1) print("Guess again! ") usrNumber = input("Guess: ") #If guess is right print("Congratz! You guessed my number! ") print("The number was " + str(theNumber) + "! ") print("It took you " + str(count) + " tries to get it right! ")
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