generate functionWed, 01 Mar 2023

At each iteration of the loop, an integer is entered. It is necessary to calculate the product of only positive numbers, until the value 0 is entered. Implement skipping calculations using the continue statement, and also use a while loop. Display the result of the work.

def get_positive_sum(): total = 0 while True: user_input = int(input('Enter a number (0 to exit): ')) if user_input == 0: break elif user_input < 0: continue else: total += user_input return total get_positive_sum()

Questions about programming?Chat with your personal AI assistant