anwser=str(input("Do you need a new phone? "))
if answer== "no":
print ("You are now finished. ")
else:
question1=str(input("Do you know what phone you want? ")
if question1== "no":
print("Research different phones and chose which pne you like best.")
else:
question2=str(input("Do you want to go on a contract? ")
if question2== "no":
question3=str(input("Do you have enought money to pay full price for your phone? ")
怎么了?我该如何改善?它不断出现语法错误,我不知道为什么。
最佳答案
您在问题线上缺少右括号:
question1 = str(input("Do you know what phone you want? ")
应该:
question1 = str(input("Do you know what phone you want? "))
您也不需要将输入转换为字符串,因为
input()
已经为您做到了:input([prompt])
If the prompt argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that.
关于python - 我的python代码出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33595790/