Skip to content

Instantly share code, notes, and snippets.

@sleepypioneer
Created August 15, 2018 11:01
Show Gist options
  • Save sleepypioneer/f164d95eb8bbe60cf89919af5b07e6b9 to your computer and use it in GitHub Desktop.
Save sleepypioneer/f164d95eb8bbe60cf89919af5b07e6b9 to your computer and use it in GitHub Desktop.
Rework of number guess game by @IntotheLine
# This is a number guess game.py
import random
print("Hey, whats your name")
name = input()
print("Choose your difficulty by entering 1 = easy, 2 = normal, 3 = hard")
game = int(input())
while game > 3 or game < 1:
print("error, please enter a number between 1 and 3")
game = int(input())
Options = {1: random.randint(1, 20), 2: random.randint(1, 100), 3: random.randint(1, 1000)}
secretNumber = Options.get(game)
print("Take a guess at the secret number")
for guessTaken in range(1, 7):
guess = int(input())
if guess == secretNumber:
print("Congratulations!")
break
elif guessTaken == 6:
print("Better luck next time. Correct is " + str(secretNumber))
elif guess < secretNumber:
print("lowbob")
elif guess > secretNumber:
print("highbob")
print("----------GAME OVER -------------")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment