提交 2fa888e5 编写于 作者: Q qq_42630327

Fri Jul 26 17:36:00 CST 2024 inscode

上级 29e92c29
......@@ -27,3 +27,24 @@ coverage
*.njsproj
*.sln
*.sw?
import random
def generate_mole():
return random.randint(1, 5)
def game_loop():
score = 0
while True:
mole_position = generate_mole()
user_input = input("A mole appeared at position {}. Hit it! (1-5): ".format(mole_position))
if user_input.isdigit() and int(user_input) == mole_position:
print("You hit the mole!")
score += 1
else:
print("Missed!")
play_again = input("Play again? (yes/no): ")
if play_again.lower() != "yes":
print("Game over. Your final score is: ", score)
break
game_loop()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册