[Tutor] IndexError and appending to lists [Was: Re: Need Help on Assignment]

Tom Strickland tlinux at comcast.net
Wed Aug 24 03:13:23 CEST 2005


Danny,

I changed the program in accordance with your advice and it now runs 
perfectly!!!

Thanks for the education!

Tom Strickland

Danny Yoo wrote:

>[Danny]
>  
>
>>>Anyway, this doesn't answer the problem: how do we add elements to a
>>>list? In Python, we can accumulate elements in a list by append()ing:
>>>      
>>>
>
>[code cut]
>
>
>[Tom]
>  
>
>>So, for example, would I use the following in my "while" loop:
>>
>>                      date.append(T[N][0])
>>
>>Before the loop, date would have to be defined as date =[], is this
>>correct?
>>    
>>
>
>Yes.  Each of the list variables that you're accumulating should each be
>initialized to an empty list.
>
>Good luck!
>
>
>
>  
>




More information about the Tutor mailing list