+ 3
Could someone explain how can i use an empty list?
5 Answers
+ 4
Okay...this question is crazy old and the OP's not active...so this "special-case" answer is for others.
* You can use empty lists to persist data across function calls, as shown here:
http://docs.python-guide.org/en/latest/writing/gotchas
"Mutable Default Arguments"
-When the Gotcha Isn't a Gotcha
...when you "exploit" or intend the function to maintain state between calls of a function
...such as a "caching function"
+ 3
you introduce it like that
>>>list =[]
and it is used when you want to append some specific values into it. Hope i helped
+ 3
Imagine you're going to the store. You take a sheet of paper and title it: Grocery List. That title, equates in code to your empty list. What you add or take from the list, from there, is up to you.
+ 1
For exemple you can fill it with generating for it random numbers or with the user's input
0
list=[]