Question #253274

Write a program that asks the user for a magic number. While the user cannot guess the magic number which is 7, ask the user again for another guess. If the guess is incorrect, print "That is not the magic number" or else if the guess is correct, print "You have guessed it".

Expert's answer

i = 0
j = 7

while i == 0:
    m = int(input('Enter number here: '))
    if j != m:
        print('That is not the magic number')
    else:
        print('You have guessed it')
        break
Enter number here: 8
That is not the magic number
Enter number here: 3
That is not the magic number
Enter number here: 7
You have guessed it
LATEST TUTORIALS
APPROVED BY CLIENTS