+ 3

Whats the use of an empty list?

24th Sep 2016, 1:41 PM
Tejas Vernekar
Tejas Vernekar - avatar
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.
30th Sep 2016, 2:19 PM
Christine Fleming (PyGirl)
Christine Fleming (PyGirl) - avatar
+ 2
i think if you ask input from the user, you can first check if the list is empty or not
26th Sep 2016, 7:06 PM
Pieter-Jan
0
Because if you declare it in the beginning this variable been for global use, for any other, it can be lost.
9th Oct 2016, 8:59 AM
Dmitrii Sky
Dmitrii Sky - avatar
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)
2nd Nov 2016, 2:43 PM
Daniel Mello
Daniel Mello - avatar