import random
numbers = []
number = str(random.randint(0, 9))
def input_check(msg,casting=str):
while True:
try:
num = casting(input('pop some nums'))
if num.isalpha():
print(num)
else:
print('press this again')
return num
except:
continue
for i in range(3):
while number in numbers:
number = str(random.randint(0,9))
numbers.append(number)
count_strike = 0
count_ball = 0
while count_strike < 3:
count_strike = 0
count_ball = 0
num = input_check('pop nums')
if len(num) == 3:
for i in range(0, 3):
for j in range(0, 3):
if num[i] == numbers[j] and i==j:
count_strike += 1
elif num[i] == numbers[j]and i!=j:
count_ball += 1
if count_strike == 0 and count_ball == 0:
print('3 out')
else:
output = ""
if count_strike > 0:
output += "{} strike".format(count_strike)
if count_ball > 0:
output += "{} ball".format(count_ball)
print(output)
print('exit')
터미널에서 무한 루프가 돌면서
계속 답이 안나오네요 ㅠㅠ 뭐가 문젠지 정확하게 파악이 안되서
코드 올려서 질문 드립니다!