IF命令中的语法错误

时间:2018-05-08 19:41:28

标签: if-statement syntax

print ('Here are the availible currency choices for today:')  
currencylist = ['US Dollar','Kenyan Shilling','Brazilian Real','Canadian 
Dollar','Indian Rupee','Philippine Peso','Indonesian Rupiah']  
print(*currencylist, sep='\n')  
currency= input(str('Which currency would you like to choose? '))  
pound= input(float('Please enter the amount you would like to exchange. £')  
if currency == ('US Dollar')  
    rate= 1.52  
    print rate

当我尝试定义rate变量时,我不断收到语法错误。有什么想法吗?

2 个答案:

答案 0 :(得分:1)

你使用这个

if (currency == 'US Dollar')  {

    rate= 1.52  
    print rate
}

答案 1 :(得分:0)

if在条件结束时需要冒号:

if currency == 'US Dollar': rate = 1.52

相关问题