Beginner
Fix the shared basket
The starter function remembers items between calls, because its default basket=[] is created only once. Rewrite it as add_item(item, basket=None) so that each call without a basket starts with a fresh empty list.
It must append the item to the basket and return the list. If the caller passes a list, use and change that list.
What Check tests
add_item("apple")returns['apple']- A second call starts fresh
- A list passed in is used
- An empty list passed in is still used
- The default is
None
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.