generate functionWed, 22 Feb 2023

n = int(input()) full = False stuffVolume = [] while full == False: x = int(input()) if (sum(stuffVolume + [x])) < n: stuffVolume.append(sum(stuffVolume + [x])) else: full = True print(sum(stuffVolume)) print(len(stuffVolume))

def add_to_list(stuffVolume): n = int(input()) full = False while full == False: x = int(input()) if (sum(stuffVolume + [x])) < n: stuffVolume.append(sum(stuffVolume + [x])) else: full = True return stuffVolume stuffVolume = [] add_to_list(stuffVolume) print(sum(stuffVolume)) print(len(stuffVolume))

Questions about programming?Chat with your personal AI assistant