Jumping around when assigning elements
Matthew Sims
matt at killermookie.org
Mon Dec 15 17:08:58 EST 2003
Python Newbie here. This is my first time learning object-oriented
programming and trying to break out of the usual Korn/Perl/PHP style
of programming. Having some difficulty understand some items.
For lists, I understand this:
C=["need","some","help"]
print C[1]
some
But I can't seem to do this:
C[3]="here"
I know about C.append("here") but this brings me to my question...
Is there anyway to assign to an element that wasn't defined in the
beginning? Like if I wanted element 5 assigned but not element 4
without using "" or None?
I'm currently re-writing a Perl script into Python and with Perl I was
free to assign any element in the array without having to fill in the
previous elements. I can't seem to do that in Python...unless I'm
doing it wrong.
Thanks
--Matt
More information about the Python-list
mailing list