Advertisement
yiorgos

number guessing game

Feb 17th, 2018
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. import random
  2.  
  3. name = input("What is your name?")
  4. print("Hello " + name + ". Let's play a game.")
  5.  
  6. while True:
  7.   secret = random.randint(1, 101)
  8.   while True:
  9.     guess = int(input("Choose a number from 1 to 100:"))
  10.     if guess == secret:
  11.       print("Congratulations!")
  12.       break
  13.     elif guess < secret:
  14.       print("The number is higher")
  15.     else:
  16.       print("The number is smaller")
  17.  
  18.   play = input("Play another game?")
  19.   if play == "yes" or play == "Yes":
  20.     continue
  21.   else:
  22.     print("Bye!")
  23.     break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement