Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- print("I'm thinking of a number between 1 and 100\n")
- print("Try to guess it in 5 attempts\n")
- guess_total = 0
- random_number = int(random.randint(1, 100))
- my_number = int(input("Introduceti numarul: "))
- #print(random_number)
- while guess_total <=4:
- if guess_total >=4:
- print("You've reached the max number of tries")
- break
- elif my_number == random_number:
- guess_total += 1
- guess_total = int(guess_total)
- print("Great. You've guessed it in", guess_total,"tries")
- break
- elif my_number < random_number:
- guess_total += 1
- guess_total = int(guess_total)
- print("Your number is too low\n")
- # print(guess_total)
- my_number = int(input("Insert number: "))
- elif my_number > random_number:
- guess_total += 1
- guess_total = int(guess_total)
- print("Your number is too high")
- # print(guess_total)
- my_number = int(input("Introduceti numarul: "))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement