我是python新手,找不到错误所在。Python说有语法错误,但它不会告诉我它在哪里。我的任务是制作一个计程车计票程序。这是我的密码
distance = input("Enter the distance of the taxi ride in kilometers (km): ")
passengers = input("Enter the amount of passengers from 1 to 5: ")
cost = float(distance) + 3 - 1 * 2
if passengers == 5:
cost = cost * 2
print("The total cost of the journey is £" cost)
else:
print("The total cost of the journey is £" cost)
这个错误可能很简单,但我找不到。提前谢谢
如果您使用的是python 3.6或更高版本,则不能连接字符串,请使用f字符串:
如果要使用
print()
函数打印多个内容,则需要使用逗号将它们分隔开试试这个:
相关问题 更多 >
编程相关推荐