Skip to content

Instantly share code, notes, and snippets.

@nesffer
Created April 30, 2015 16:08
Show Gist options
  • Save nesffer/47b1345f2581805b2f07 to your computer and use it in GitHub Desktop.
Save nesffer/47b1345f2581805b2f07 to your computer and use it in GitHub Desktop.
Baseball
# -*- coding: utf-8 -*-
# 랜덤 숫자 1~5
from random import randint
a = randint(1, 5)
b = randint(1, 5)
c = randint(1, 5)
# 랜덤 숫자 1~5
# a = 2
# b = 4
# c = 7
while True:
ball = 0
strike = 0
q = int(input("첫번째 숫자를 입력하세요: "))
w = int(input("두번째 숫자를 입력하세요: "))
e = int(input("세번째 숫자를 입력하세요: "))
if (a == q) and (b == w) and (c == e):
print("Game End")
break
if (a == w) or (a == e):
ball += 1
if (b == q) or (b == e):
ball += 1
if (c == q) or (c == w):
ball += 1
if (a == q) or (b == w) or (c == e):
strike += 1
print("Ball:", ball, "Strike:", strike)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment