+ 3
Whats the use of an empty list?
4 Antworten
+ 10
While writing complex and long program codes you'll want to define your variables, constants, lists, functions in the begginning of the program so that you don't lose sight of them later.
That is the most wide usage of empty lists. You create one to be later checked, filled in or altered.
+ 2
i think if you ask input from the user, you can first check if the list is empty or not
0
Because if you declare it in the beginning this variable been for global use, for any other, it can be lost.
0
"""
You can add the elements anytime you want as in a loop interaction. this gives to you construct lists dynamically.
Run it:
"""
mylist=[1,2,3]
print(mylist)
mylist.append(4)
print(mylist)