Answer to Question #287591 in Python for bon

Question #287591

The program displays random numbers on the screen and requests for the spelling of that number. It checks if the input is correct, then it displays another number. If the input is wrong, then it will send an error message and request another answer with 3 attempts.



1
Expert's answer
2022-01-14T08:28:52-0500
from random import randint


atempt = 3
while atempt > 0:
	n = str(randint(10,999))
	print(f"number: {n}")
	user_n = input("write that number: ")
	if n != user_n:
		print("wrong, try again")
	else:
		print("right !")
		atempt = 0
	atempt -= 1

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