Make a program that draws a random number between 0 and 500 and asks the user what the "magic number" is. The program should indicate whether the attempt made by the user is greater or less than the magic number and count the number of attempts. When the user manages to hit the number, the program should classify the user as: List compiled by Prof. Robson R. Linhares – DAINF/CEFET-PR/UTFPR The. From 1 to 3 attempts: very lucky B. From 4 to 6 attempts: lucky w. 7 to 10 attempts: normal d. > 10 attempts: try again
import random number = random.randint(0, 500) magic_number = int(input('Enter the magic number: ')) attempts = 0 while magic_number != number: if magic_number > number: print('The magic number is less!') else: print('The magic number is greater!') magic_number = int(input('Enter the magic number: ')) attempts += 1 print('You got it in {} attempts!'.format(attempts)) if attempts in range(1, 3): print('Very lucky!') elif attempts in range(3, 6): print('Lucky!') elif attempts in range(7, 10): print('Normal!') else: print('Try again!')