Python 入門指南 5.0
exercise2706.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 | # 從 exercise2705 引入 Guess
from exercise2705 import Guess
# 執行部分
if __name__ == '__main__':
# 建立遊戲答案
g = Guess(4)
# 印出提示訊息
print("歡迎來到猜數字遊戲")
# 取得使用者輸入
user_input = input("請輸入四個不重複數字:")
# 進行猜測
if g.repeat_test(user_input):
result = g.find_AB(user_input)
if result == "4A":
print("恭喜猜對")
else:
print(result)
else:
print("請不要輸入重複數字或超過、少於四個數字")
# 檔名: exercise2706.py
# 說明:《Python入門指南》的練習
# 網站: http://kaiching.org
# 作者: 張凱慶
# 時間: 2023 年 11 月
|