я получаю неожиданный характер после ошибки символа продолжения строки в этой строкеЯ получаю неожиданный характер после ошибки символа продолжения строки
print (\t,"Order total $",format(total, "10.2"),\n\t,"Discount $",format(disc,"10.2"),\n\t,"Amount Due $",format (due, "10.2"),sep="")
кто-то может сказать мне, что это значит и как это исправить? благодаря
def finddiscount(quantity):
if quantity >= 1 and quantity <= 9:
discount = 0
elif quantity >= 10 and quantity <= 19:
discount = .2
elif quantity >= 20 and quantity <= 49:
discount = .30
elif quantity >= 50 and quantity <= 99:
discount = .40
elif quantity >= 100:
discount = .50
def calctotal(quantity, price):
disc = (price*quantity)*finddiscount(quantity)
total = (price*quantity)
due = (price*quantity)-(price*quantity)*dicount
print (\t,"Order total $",format(total, "10.2"),\n\t,"Discount $",format(disc,"10.2"),\n\t,"Amount Due $",format (due, "10.2"),sep="")
def main():
quantity = int(input("How many packages where purchased?"))
price = float(input("How much is each item?"))
calctotal(quantity, price)
main()
Не добавляйте 'g' там без причины. Чтобы получить точно такие же результаты, как 'format (...," 10.2 ")' просто используйте '{: 10.2}'. – abarnert