Advertisement
furas

Python - Guessing two numbers.

Aug 3rd, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.31 KB | None | 0 0
  1. #
  2. # https://www.reddit.com/r/learnpython/comments/4vxv9g/need_some_help/
  3. #
  4.  
  5. import random
  6.  
  7. while True:
  8.  
  9.     while True:
  10.         num1 = int(input("Enter a number between 1 and 25: "))
  11.         if num1 > 25:
  12.             print("You must select a number less than 25!")
  13.         else:
  14.             break
  15.    
  16.     while True:
  17.         num2 = int(input("Enter another number betwenn 1 and 25: "))
  18.         if num2 > 25:
  19.             print("You must select a number less than 25!")
  20.         else:
  21.             break
  22.        
  23.     num3 = random.randrange(1, 25)
  24.     num4 = random.randrange(1, 25)
  25.  
  26.     print("You picked {} and {}".format(num1, num2))
  27.  
  28.     if num1 == num3:
  29.         print("CONGRAGULATIONS!!! YOU GUESSED RIGHT!!!")
  30.     else:
  31.         print("Sorry you were not correct the first number was:", num3)
  32.        
  33.     if num2 == num4:
  34.         print("CONGRAGULATIONS!!! YOU GUESSED RIGHT!!!")
  35.     else:
  36.         print("Sorry you were not correct the second number was:", num4)
  37.    
  38.     print("End of guessing game")
  39.     print("Would you like to try again? yes or no")
  40.    
  41.     user_input = input(": ").lower()
  42.    
  43.     # if user_input in ('no', 'n'):
  44.     # if user_input and user_input[0] == 'n': # if len(user_input) > 0 and user_input[0] == 'n'
  45.     if user_input == "no" or user_input == "n":
  46.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement