Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions rock_paper_scissors.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,30 @@ def main():
print("=========================================")
print(" Rock, Paper, Scissors")
print("=========================================")
print("Enter your choice:")
print(" Rock")
print(" Paper")
print(" Scissors")
print("=========================================")

# Get player input
player_choice = input("Your choice: ").capitalize()

# Validate input
if player_choice not in ['Rock', 'Paper', 'Scissors']:
print("\nInvalid choice. Please enter Rock, Paper, or Scissors.")
return

computer_choice = get_computer_choice()

determine_winner(player_choice, computer_choice)
while True:
print("\nEnter your choice:")
print(" Rock")
print(" Paper")
print(" Scissors")
print("=========================================")

# Get player input
player_choice = input("Your choice: ").capitalize()

# Validate input
if player_choice not in ['Rock', 'Paper', 'Scissors']:
print("\nInvalid choice. Please enter Rock, Paper, or Scissors.")
continue # 如果输入无效,重新开始本轮

computer_choice = get_computer_choice()
determine_winner(player_choice, computer_choice)

# Ask if want to play again
play_again = input("\nPlay again? (y/n): ").strip().lower()
if play_again != 'y':
print("\nThanks for playing! Goodbye!")
break

if __name__ == "__main__":
main()