import random flag True while flag num input Type any number to start

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import random
flag = True
while flag:
num = input('Type any number to start the game. ')
if num.isdigit():
print("Let's play! Try to guess a number I am thinking of. You have only 5 tries!")
flag = False
else:
print('Invalid input! Try again.')
secret = random.randint(1, 10)
guess = None
count = 0
while guess != secret:
guess = input()
if guess.isdigit():
guess = int(guess)
if guess == secret:
print('You got it!')
if guess != secret:
print()
count += 1
if count != 5:
print('Please try again!')
if count == 5:
print('Nope! I was thinking about ' + str(secret) + ' :(')
break
print('It took you', count, 'guesses.')