python-2.7 - 我的 Python 2.7 代码中有语法错误。我需要帮助
问题描述
每当我运行它时,它都会给我这个语法错误:
File "main.py", line 27
decide_winner (user_choice, computer_choice)
^
IntendationError: unexpected indent
我不知道如何解决这个问题,我已经研究了大约两天了,我真的是专家的帮助。
from random import randint
options = ['ROCK','PAPER','SCISSORS']
message = {"tie': 'you've tied",
"won': 'you've won!",
"lost': 'you've lost!"
}
def decide_winner(user_choice, computer_choice):
print 'you chose %s' % user_choice
print 'computer chose %s' % computer_choice
if user_choice == computer_choice:
print message['tie']
elif user_choice == options[0] and computer_choice == options[2]:
print message['won']
elif user_choice == options[1] and computer_choice == options[0]:
print message['won']
elif user_choice == options[2] and computer_choice == options[1]:
print message['won']
else:
print message['lost']
def play_RPS():
user_choice = raw_input('Enter ROCK PAPER or SCISSORS')
user_choice = user_choice.upper()
computer_choice = options[randint(0,2)]
decide_winner(user_choice, computer_choice)
play_RPS()
解决方案
推荐阅读
- spring-boot - Gradle BOM 项目
- c# - 如何在 COM 事件源和处理程序中指定“事件类型”?
- python - 闰年while循环
- kotlin - 对象中的泛型
- flutter - 升级后:flutter_google_places - 自动完成不显示推荐列表
- java - 启动层初始化时出错 java.lang.module.FindException: Module SimpleJavaProgram not found
- node.js - 使用 blob http 在 node.js 中进行音频流式传输,与自然阅读器在读取 pdf 音频时的方式相同
- amazon-cloudformation - 了解 AWS CodePipeline 中的 CloudFormationStackSet 和 CloudFormationStackInstances 操作
- jquery-ui - jQuery UI Widget Factory,修改Draggable的开始、拖动、停止
- database - 通过托管在 firebase 上的网站将图片上传到数据库是否安全?