我有一个函数,我认为是一个语法错误,因为我没有正确结束它 我认为的问题是我没有命令来结束 def get_input():所以函数没有结束,并且给出了main()语法无效的错误。
def main():
pennies = get_input("Enter pennies : ")
nickels = get_input("Enter nickels : ")
dimes = get_input("Enter dimes : ")
quarters = get_input("Enter quarters : ")
print("You entered : ")
print("\tPennies : " , pennies)
print("\tNickels : " , nickels)
print("\tDimes : " , dimes)
print("\tQuarters : " , quarters)
total_value = get_total(pennies, nickels, dimes, quarters)
dollars = get_dollars(pennies, nickels, dimes, quarters)
left_over_cents = get_left_over_cents(pennies, nickels, dimes, quarters)
print("Total = $", total_value, sep="")
print("You have", dollars, "dollars and", left_over_cents, "cent(s)")
def get_input():
currency = 0
while currency < 0:
print('ERROR: Money cannot be negative.')
currency = int(input("Enter correct values")
main()
答案 0 :(得分:2)
您在get_input
的最后一行错过了一个近似括号。
currency = int(input("Enter correct values"))
# ^ here