프로그래밍 처음 소개. 난수를 추측 할 때 반복 (시도) 횟수를 계산하고 인쇄하는 방법? '3 번째 시도에서의 수를 추측 해 보겠습니다.루프 반복 계산 횟수
import random
from time import sleep
str = ("Guess the number between 1 to 100")
print(str.center(80))
sleep(2)
number = random.randint(0, 100)
user_input = []
while user_input != number:
while True:
try:
user_input = int(input("\nEnter a number: "))
if user_input > 100:
print("You exceeded the input parameter, but anyways,")
elif user_input < 0:
print("You exceeded the input parameter, but anyways,")
break
except ValueError:
print("Not valid")
if number > user_input:
print("The number is greater that that you entered ")
elif number < user_input:
print("The number is smaller than that you entered ")
else:
print("Congratulation. You made it!")
'카운터 = 0; while user_input! = number : count + = 1' – AChampion
당신은 Thaaaaaaaank you !! –