Python Conditionals, Lists, Dictionaries, and Operators - Tuples (Page 4 of 6 )
Another way to store more than one piece of data is through tuples. Tuples work exactly like lists, except the data within them cannot be changed. And you assign value with parentheses instead of brackets. Observe!
#!/usr/local/bin/python
suess = ('I', 'like', 'green', 'eggs', 'and', 'spam')
print suess
print suess[1]
Resulting in:
I like green eggs and spam
like
You will notice that you still access an element with the brackets.
Next: Dictionaries >>
More Python Articles
More By James Payne