我正在编写一个程序,它接受用户输入并将其与不同的命令字符串进行比较.当我尝试运行该程序时,我得到一个SyntaxError关于该行if method = 'addition':,IDLE突出显示为=红色.
num1 = input('Enter your first value: ')
num2 = input('Enter your second value: ')
method = input('Which method will you be using? ')
if method = 'addition':
solveFor = num1 + num2
elif method = 'subtraction':
solveFor = num1 - num2
else:
print("Please enter 'addition' or 'subtraction'")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15002 次 |
| 最近记录: |