My task is to write a code that will add integers until user decides to quit the program with "Q". The program has two modules that user can choose - in the first ("A") prints each number and their total and in the second ("T") it prints only total.
I wrote the program, the only problem is when opting for module "A" I don't know how to print each numb in elif statement before print("Items"). For example if I input 4, 5, 10 before "Q" and print(num) above line print(Total) it will only print me 10 and I want 4,5,10.
Ideas are appreciated.
def adding_report(choose):
total = 0
print("Enter an integer to add to the total or Quit.")
while True:
if choose == "A":
numb = input('Enter an integer or "Q": ')
if numb.isdigit():
total = total + int(numb)
elif numb.startswith("Q"):
print("Items")
print("Total")
print(total)
else:
print("Invalid input!")
if choose == "T":
numb = input('Enter an integer or "Q": ')
if numb.isdigit():
total = total + int(numb)
elif numb.startswith("Q"):
print("Total")
print(total)
else:
print("Invalid input!")
adding_report(input("Choose report type(A or T): ")) I wrote the program, the only problem is when opting for module "A" I don't know how to print each numb in elif statement before print("Items"). For example if I input 4, 5, 10 before "Q" and print(num) above line print(Total) it will only print me 10 and I want 4,5,10.
Ideas are appreciated.
