추가 '야구 게임'

This commit is contained in:
kim_yubin 2018-11-02 19:13:18 +09:00
parent 56bbea4b7d
commit c62ed1af6e
1 changed files with 44 additions and 0 deletions

44
야구 게임 Normal file
View File

@ -0,0 +1,44 @@
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("게임 종료")