diff --git a/other/guess_the_number_userplay.py b/other/guess_the_number_userplay.py new file mode 100644 index 000000000000..3085c4046074 --- /dev/null +++ b/other/guess_the_number_userplay.py @@ -0,0 +1,33 @@ +import random + + +def guess(): + print("🎯 Welcome to Guess the Number game!") + print("Rules are simple, guess a number between 0 and 20, and enter it below.") + print("Only 5 Attempts are possible") + print() + + computer = random.choice(range(21)) + print("Alright, let’s go! Type your first guess πŸ‘‡") + print() + + print(computer) + + count = 0 + while True: + user = int(input("Number: ")) + if count == 5: + print("Try again, max only 5 Attempts") + break + if user == computer: + print("πŸ”₯ Success! You've guessed it right!") + break + elif user < computer: + print("Try some higher numbers!") + count += 1 + elif user > computer: + print("Not that high, try lower ones!") + count += 1 + + +guess()