44 lines
1018 B
Plaintext
44 lines
1018 B
Plaintext
|
|
import random
|
||
|
|
strike=0
|
||
|
|
t=0
|
||
|
|
chare=['첫', '두', '세']
|
||
|
|
randomInt=[]
|
||
|
|
inputInt=[]
|
||
|
|
|
||
|
|
while t<3: ## 난수 생성
|
||
|
|
a = random.randint(0, 9)
|
||
|
|
if not a in randomInt:
|
||
|
|
randomInt.append(a)
|
||
|
|
t += 1
|
||
|
|
|
||
|
|
print(randomInt) ## 난수 확인
|
||
|
|
|
||
|
|
while strike<3: ## 스트라이크가 다 나올 때까지 계속 반복
|
||
|
|
strike=0
|
||
|
|
ball=0
|
||
|
|
out=0
|
||
|
|
t=0
|
||
|
|
w=0
|
||
|
|
inputInt=[]
|
||
|
|
|
||
|
|
while w<3: ## 입력 반복
|
||
|
|
b=int(input(chare[w] + " 번째 수를 입력 : "))
|
||
|
|
inputInt.append(b)
|
||
|
|
w+=1
|
||
|
|
|
||
|
|
for u in inputInt: ## 스트라이크, 볼, 아웃 비교
|
||
|
|
if u in randomInt:
|
||
|
|
if u is randomInt[t]:
|
||
|
|
strike+=1
|
||
|
|
else:
|
||
|
|
ball+=1
|
||
|
|
else:
|
||
|
|
out+=1
|
||
|
|
t+=1
|
||
|
|
|
||
|
|
if out is 3: ## 결과 출력
|
||
|
|
print("아웃, 다시")
|
||
|
|
else:
|
||
|
|
print(str(strike) + " 스트라이크 " + str(ball) + " 볼 ")
|
||
|
|
|
||
|
|
print("게임 종료")
|