Dec-15-2022, 04:47 PM
(Dec-15-2022, 04:16 PM)deanhystad Wrote:from itertools import cycle baskets = [] items = [] while basket := input("Basket: "): baskets.append([basket]) while item := input("Items: "): items.append(item) for basket, item in zip(cycle(baskets), items): basket.append(item) print(baskets)
Output:Basket: A Basket: B Basket: Items: 1 Items: 2 Items: 3 Items: 4 Items: 5 Items: [['A', '1', '3', '5'], ['B', '2', '4']]
That of course works great!! Thank you, now I have to study more on zip and cycle to see why it works...
Thanks again for your help and patience
DeatZ