[Tutor] Initializing Tupples
Jonathon
jblake@stamp-coin.com
Fri, 27 Aug 1999 19:46:12 +0000 (UTC)
On Wed, 25 Aug 1999, Joseph J. Strout wrote:
>So there must be a difference between what you're telling us, and
Source code from the program I am writing is available at
http://www.stamp-coin.com/python/script-error/index.html
>copy of Python is seriously screwed up (unlikely). Or, this error
>occurs not on the code you gave us, but on later code where you try
>to...
Possible.
>Well, you can't. You need to use a list for that; tuples are immutable.
Let's see if I understand the difference between lists and
tuples.
Once a Tuple is created, it can not be changed.
Once a List is created, both it, and its contents can
be changed --- increased, decreased etc.
IE:
Example_Tuple = ( "joe"0, "curly", "moe" )
and Example_Tuple retains that value for the duration
of the program.
Example_List = [ "joe", "curly", "moe" ]
Example_List[0] = "larry"
Changes the 0 element to larry.
Example_List.insert(3, "joe")
Adds "joe" to the list, as the third element.
Example_List[3] = 2
Makes that a number, instead of a string.
<< All this appears to work at the python prompt. >>
xan
jonathon