Skip to content

Commit 29aee5c

Browse files
committed
[swthewhite-lab#4] Add: a function that repeats the process from 1 to 3 and the game ends when all 3 numbers are guessed correctly
1 parent fa83c50 commit 29aee5c

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

docs/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
2. player_input()
55
> 플레이어에게 3개의 숫자 입력 받는 기능 함수 추가 (2025/02/05)
66
3. check_input()
7-
> 플레이어가 입력한 숫자에 대한 결과를 출력하는 함수 추가 (2025/02/05)
7+
> 플레이어가 입력한 숫자에 대한 결과를 출력하는 함수 추가 (2025/02/05)
8+
4. loop_check()
9+
> 1에서 3까지의 과정을 반복해 3개의 숫자를 모두 맞히면 게임이 종료되는 기능 함수 추가 (2025/02/05)

src/baseball/main.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ def check_input(get, com):
2727
return "{0}볼".format(ball)
2828
else:
2929
return "{0}볼 {1}스트라이크".format(ball, strike)
30+
31+
def loop_check(com):
32+
get = player_input()
33+
result_check_input = check_input(get, com)
34+
print(result_check_input)
35+
if result_check_input != "3스트라이크":
36+
loop_check(com)
3037

3138
def main():
3239
"""
@@ -36,8 +43,9 @@ def main():
3643
# 프로그램의 메인 로직을 여기에 구현
3744
print("숫자 야구 게임을 시작합니다.")
3845
computer = make_computer_num()
39-
get = player_input()
40-
print(check_input(get, computer))
46+
print(computer)
47+
loop_check(computer)
48+
print("3개의 숫자를 모두 맞히셨습니다! 게임 종료")
4149

4250
if __name__ == "__main__":
4351
# 프로그램이 직접 실행될 때만 main() 함수를 호출

0 commit comments

Comments
 (0)