Define add_item(item, items=None) that creates a new list if items is None, appends item, and return
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
Problem
Define add_item(item, items=None) that creates a new list if items is None, appends item, and returns the list. Print add_item("a"), then print add_item("b") to show each call gets a fresh list.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.