generate functionWed, 22 Feb 2023

the total sum of integers entered on a new line must not exceed 'n'. before the sum exceeds for one input before exceeding it is necessary to print the word 'enough' and the sum of the input chichel and the number of numbers without taking into account the last input that exceeded 'n'

n = int(input()) i = 0 sum = 0 while True: sum += int(input()) i += 1 if sum > n: break else: print(i, sum)

Questions about programming?Chat with your personal AI assistant