loading

Step 1: The Code

After opening a blank python file, type the following code:

--- = tab

import random
goAgain = True
while goAgain == True:
---gameMode = input("EASY/MEDIUM/HARD ")
---if gameMode in ['easy', 'Easy', 'EASY']:
------chosenNumber = random.randint(1,100)
------print("I'm thinking of a number between 1 and 100")
------guessesTaken = 0
------playerGuess = 'void'
------while playerGuess != chosenNumber:
---------playerGuess = input("Guess a number: ")
---------if playerGuess > chosenNumber:
------------print("Too High")
---------else:
------------print("Too Low")
------print("You Guessed It!")


---if gameMode in ['medium', 'Medium', 'MEDIUM']:
------chosenNumber = random.randint(1,1000)
------print("I'm thinking of a number between 1 and 1000")
------guessesTaken = 0
------playerGuess = 'void'
------while playerGuess != chosenNumber:
---------playerGuess = input("Guess a number: ")
---------if playerGuess > chosenNumber:
------------print("Too High")
---------else:
------------print("Too Low")
------print("You Guessed It!")


---if gameMode in ['hard', 'Hard', 'HARD']:
------chosenNumber = random.randint(1,10000)
------print("I'm thinking of a number between 1 and 10000")
------guessesTaken = 0
------playerGuess = 'void'
------while playerGuess != chosenNumber:
---------playerGuess = input("Guess a number: ")
---------if playerGuess > chosenNumber:
------------print("Too High")
---------else:
------------print("Too Low")
------print("You Guessed It!")

---goAgainPrompt = input("Do you want to go again (Y/N) ")
---if goAgainPrompt in ['y', 'Y', 'Yes', 'YES']:
------goAgain = True
---else:
------goAgain = False
Cool idea! I have a suggestion for you. When asking the user what level of difficulty use this: input('easy,medium,hard').lower( ) // by doing this you will not have to worry about the exact input as it will always revert to lower case.

About This Instructable

1,061views

18favorites

License:

Bio: 1 new python tutorial every day Comment what you want the next one to be Please favourite and subscribe Notice Board: - since instructables has automatically ... More »
More by BlueBlood Studios:Teach Me Python #7: Control Statements Pt.2: While Loops Teach My Python #6: Control Statements Pt.1: If, Else And Elif Teach Me Python #5: Simple Maths 
Add instructable to: