我需要我的“items”变量将每个项目打印到新行上。我总是在“items”中得到总数,在“total”中得到总数。“总计”打印出我想要的结果,但我希望这些项目单独打印。在
有什么想法?在def adding_report():
user_input = input("Report Types include All Items ('A') or Total Only ('T')\nChoose Report Type ('A'or'T'):")
items = "\n"
total = 0
while True:
if user_input == 'A'.lower():
user_input1 = input("Input an integer to add to the total or 'Q' to quit: ")
if user_input1.isdigit():
items = int(user_input1)
total += int(user_input1)
continue
elif user_input1 == 'Q'.lower():
print("Items\n", items)
print("Total\n", total)
break
elif user_input1.startswith('q'):
print('Items\n', int(items))
print("Total\n", total)
break
else:
print("Input is not valid")
elif user_input == 'T'.lower():
user_input2 = input("Input an integer to add the total or 'Q' to quit: ")
adding_report()