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? ")
有什么问题?我该如何改进?它不断出现语法错误,我不知道为什么。
答案 0 :(得分:3)
您在问题专栏中缺少右括号:
question1 = str(input("Do you know what phone you want? ")
应该是:
question1 = str(input("Do you know what phone you want? "))
您也不需要将输入转换为字符串,因为input()
已经为您执行了此操作:
input([prompt])
如果存在提示参数,则将其写入标准输出 没有尾随换行符。然后该函数从输入中读取一行, 将其转换为字符串(剥离尾随换行符),然后返回 这一点。