from itertools import cycle baskets = [] items = [] while basket := input("Basket: "): baskets.append([basket]) while item := input("Items: "): items.append(item) # Poof! Magic happens! basket.append(item) print(baskets)I can't finish my inputs and get this:
Error:C:\Users\david\PycharmProjects\pythonProject\venv\Scripts\python.exe E:\DropBoxFiles\Dropbox\Programming\Python\ittertools_v2.py
Basket: a
Basket: b
Basket: c
Basket:
Items: 1
Traceback (most recent call last):
File "E:\DropBoxFiles\Dropbox\Programming\Python\ittertools_v2.py", line 12, in <module>
basket.append(item)
^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'append'
Process finished with exit code 1
I'm using PyCharm, dunno if that makes a difference.I appreciate all your help, it's frustrating that a seemingly simple task is wrecking my brain.