total = 0
A1 = ["Big Mac", float(2.50), 50]
B1 = ["Large Fries", float(0.50), 200]
C1 = ["Vegetarian Burger", float(1.00), 20]
print(A1[0:2])
print(B1[0:2])
print(C1[0:2])
while True:
choice = (input("What would you like?")).upper()
quantity = float(input("How many would you like?"))
if choice == "BIG MAC":
if quantity > A1[2]:
print("There is not enough stock!")
pass
else:
total += A1[1]*quantity
A1[2] -= quantity
elif choice == "LARGE FRIES":
if quantity > B1[2]:
print("There is not enough stock!")
pass
else:
total += B1[1]*quantity
B1[2] -= quantity
elif choice == "VEGETARIAN BURGER":
if quantity > C1[2]:
print("There is not enough stock!")
pass
else:
total += C1[1]*quantity
C1[2] -= quantity
more_items = (input("Do you want to order more items?")).lower()
if more_items == "yes":
pass
else:
break
print("Thank you for ordering!\n"
"Your total cost is:", total)
我正在尝试通过column = column >= (numberOfColumns - 1) ? 0 : ++column
符号增加我的列变量,但现在已弃用。这个增量的最佳标志是什么?
我尝试了++
和column++
。虽然它在正常的if-else条件下工作,但我想通过内联条件实现它。
答案 0 :(得分:0)
简单的增量怎么样?
column = column >= (numberOfColumns - 1) ? 0 : column + 1