Answer to Question #253274 in Python for jam

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".
1
Expert's answer
2021-10-19T02:05:50-0400
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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS