Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2015
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. import random
  2. print("I'm thinking of a number between 1 and 100\n")
  3. print("Try to guess it in 5 attempts\n")
  4.  
  5. guess_total = 0
  6. random_number = int(random.randint(1, 100))
  7. my_number = int(input("Introduceti numarul: "))
  8. #print(random_number)
  9.  
  10. while guess_total <=4:
  11.     if guess_total >=4:
  12.         print("You've reached the max number of tries")
  13.         break
  14.  
  15.  
  16.     elif my_number == random_number:
  17.         guess_total += 1
  18.         guess_total = int(guess_total)
  19.         print("Great. You've guessed it in", guess_total,"tries")
  20.         break
  21.  
  22.     elif my_number < random_number:
  23.         guess_total += 1
  24.         guess_total = int(guess_total)
  25.         print("Your number is too low\n")
  26.  #       print(guess_total)
  27.         my_number = int(input("Insert number: "))
  28.     elif my_number > random_number:
  29.         guess_total += 1
  30.         guess_total = int(guess_total)
  31.         print("Your number is too high")
  32.  #       print(guess_total)
  33.         my_number = int(input("Introduceti numarul: "))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement