generate functionThu, 16 Feb 2023

The user enters integers one per line, the sequence ends with the number 0. Anything after 0 is not part of the sequence. Write a program that prints the sum of all terms in a given sequence.

def add_sequence(): sum = 0 while True: num = int(input('> ')) if num == 0: break else: sum += num print(sum)

Questions about programming?Chat with your personal AI assistant