[英]Python prints statement for each line in txt file
我想接受用户的输入(一个整数),并使用它来乘以列表中的第三个参数。 我不知道该如何处理我当前使用的代码:
def add_cart():
cart_YorN = ""
while cart_YorN not in ("y", "n"):
cart_YorN = input("\nWould you like to add this item to your cart? ")
if cart_YorN == "y":
multiply = int(input("Okay, how many of this item would you like? \n")) #multiply is the variable that will carry the multiplication value
receipt_list.#????? #not sure what to do here
receive.list是包含3个参数的列表,我希望将第三个参数乘以“乘”。 另外,一旦倍增,是否会更新列表?
result = receipt_list[2] * multiply
我认为您可以使用:
receipt_list[2] *= multiply
列表的第三个元素将被更新
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.