Empty List

Pierre-Alain Dorange pdorange at pas-de-pub-merci.mac.com
Mon Jun 27 04:55:50 EDT 2016


Elizabeth Weiss <cake240 at gmail.com> wrote:

> What is the point of this code?:
> 
> word=[]
> print(word)
> 
> The result is []
> 
> When would I need to use something like this? 

You often need to intialize a list, sometime with (empty)  = [].
Then after initializing you should do "something" that perhaps will fill
the list (word.append("hello").
Then after do your job, you perhaps need to print it.

But initializing and just print, will do nothing else than initialize
and print the result...

As state before this code more or less like :

a=0
print a

-- 
Pierre-Alain Dorange               Moof <http://clarus.chez-alice.fr/>

Ce message est sous licence Creative Commons "by-nc-sa-2.0"
<http://creativecommons.org/licenses/by-nc-sa/2.0/fr/>



More information about the Python-list mailing list