<> Problem description

Write function simulation guessing game . You can specify an integer range and the maximum number of guesses by parameters , The system randomly generates an integer within the specified range , The user is then asked to guess the value of the number , The system prompts players according to their guess （ for example , Guess big , Guess it's too small , That's right ）, Players can adjust the next guess according to the system , Until you guess right or run out of times .

<> Implementation code
from random import randint def guess(start, end, maxTimes): value = randint(
start, end) for i in range(maxTimes): if i==0: prompt = 'Start to GUESS:' else:
prompt= 'Guess again:' try: x = int(input(prompt)) except: print('Must input an
integer between 1 and ', end) else: if x == value: print('Congratulations!')
break elif x > value: print('Too big') else: print('Too little') else: print(
'Game over. FAIL.') print('The value is ', value) guess(1, 10, 3)
<> Running results

Technology
Daily Recommendation
views 4