0

# Balance values from x number of lists

I have a bunch of lists numbers that contains different numbers, and the number of items within each lists differs. Eg. listA = [10, 5, 32, 8, 3] listB = [25, 22] listC = [6, 35, 1] If I am going to set a limitation where each lists can only hold up to a sum of minimum value 50, what is the best way that I can approach this?

3 Answers

New Answer

+5

So, if u are taking list input from users using loop, there in the loop, u can specify that u want a number bigger than 50.

0

Hi Arushi, I have re edited my question. Pardon for not being clear. I am not trying to find number greater than 50, but the overall sum of the lists to have a minimum value of 50

0

if you're program runs such as the user inputs number then inserting it to a List, you do this pseudo: input num if sum(list) + num >= 50 append num to list On the creation of list and you want it to have a value of > 50, just add random stuff tiLL it reach 50 import random while True: if sum(list) < 50 list.append(random.randrange(0,whatEverNumber)) else break