숫자야구프로그램 문제인데 저 정의된 함수를 써야하는데 저기 있는 def를 어떻게 하나요..
import random
c=["0","0","0"]
c[0] = str(random.randrange(1,9,1))
c[1] = c[0]
c[2] = c[0]
while (c[0] == c[1]):
c[1] = str(random.randrange(1, 9, 1))
while (c[0] == c[2] or c[1] == c[2]):
c[2] = str(random.randrange(1, 9, 1))
시도 = 1
strike = 0
ball = 0
print("I've chosen three numbers.")
print("Guess them!")
while ( strike < 3 ):
num = str(input("Enter three numbers: "))
strike = 0
ball = 0
for i in range(0, 3):
for j in range(0, 3):
if(num[i] == str(c[j]) and i == j):
strike += 1
elif(num[i] == str(c[j]) and i != j):
ball += 1
print(시도,"-th try: ", strike, " Strike ", ball, " Ball\n")
시도 += 1
print("Congratulations! You hit!")
저거 안쓰고는 이렇게 하는건 알겠는데..