Retrieving
items from a tuple:
The 1st position in a tuple is 0, 2nd position is 1, 3rd position
is 2, etc
Example:
# create a tuple
groceryList = ( "pizza", "milk", "chips", "tacos", "chicken wings")
# Retrieve 1st item from tuple
x = groceryList[0]
# Retrieve 3rd item from tuple
y = groceryList[2]
# print the first and third items
in the tuple
print(x, y)
######## it will print
"pizza", "chips"
########
Example:
# create a tuple
of float lists
worldOrientation = ([ 1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0])
# Retrieve the 2nd list in the
tuple
a =
worldOrientation[1]
# Retrieve the 1st item in the 1st
list in the tuple
b =
worldOrientation[0][0]
# print a
print(a)
# print b
print(b)
########## it will print
[0.0, 1.0, 0.0]
1.0
##########