daily pastebin goal
92%
SHARE
TWEET

Untitled

a guest Dec 14th, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2. chance = 0
  3. print('Hello! What is your name?')
  4. myName = input()
  5. magic_number = random.randint(1, 20)
  6. #print(magic_number)
  7. print('Well, ' + myName + ', please enter a number between 1 and 20.')
  8.  
  9. while chance < 5:
  10.     print('Take a guess')
  11.     user_input = input()
  12.     user_input = int(user_input)
  13.     if 20 >= user_input >= 1:
  14.         #print("valid number")
  15.         chance = chance + 1
  16.         if user_input == magic_number :
  17.             print('Good job, ' + myName + ' You guessed the number'  )
  18.        
  19.             if chance == 1:
  20.                 print("you won 50 points")
  21.             elif chance == 2:
  22.                 print("you won 40 points")
  23.             elif chance == 3:
  24.                 print("you won 30 points")
  25.             elif chance == 4:
  26.                 print("you won 20 points")
  27.             elif chance == 5:
  28.                 print("you won 10 points")
  29.             break                  
  30.         elif user_input < magic_number:
  31.             print('Your guess is too low.')
  32.         elif user_input > magic_number:
  33.             print('Your guess is too high.')       
  34.        
  35.     else:
  36.         print("Invalid number")
  37.         break
  38. else:
  39.     magic_number = str(magic_number)
  40.     print('sorry the number is ' + magic_number)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top