# 10/21/13

lists in lists

``````

In [1]:

lists = [ [1,2,3], [4,5,6], [7,8,9] ]
print lists[0]
print lists[0][0]

``````
``````

[1, 2, 3]
1

``````
``````

In [2]:

#same as
print "WorDs thAT aRE nOt CapitALiZed CorRectlY".lower().title()

``````
``````

Words That Are Not Capitalized Correctly

``````
``````

In [4]:

word_lists = [ ["cat","dog","fish"], ["red","blue","green"] ]
print word_lists[1][2].title()

``````
``````

Green

``````

is keyword

``````

In [6]:

a = 7
b = 7
print a == b
print a is b

``````
``````

True
True

``````
``````

In [8]:

a = 'dog'
b = 'dog'
print a == b
print a is b

``````
``````

True
True

``````
``````

In [10]:

a = [ 1,2 ]
b = [ 1,2 ]

print a == b
print a is b

a.append(5)
b.append(3)

print a
print b
del a
del b

``````
``````

True
False
[1, 2, 5]
[1, 2, 3]

``````
``````

In [11]:

a = [ 1, 2]
b = a

print a == b
print a is b

``````
``````

True
True

``````
``````

In [12]:

a.append(3)
print b

``````
``````

[1, 2, 3]

``````
``````

In [13]:

x = False
print x is False

``````
``````

True

``````
``````

In [15]:

a = [1,2]
b = a + [3]

print a
print b

``````
``````

[1, 2]
[1, 2, 3]

``````
``````

In [16]:

a = [1 , 2]
b = a

b = a + [3]
a = a + [3]

print a == b
print a is b

``````
``````

True
False

``````
``````

In [17]:

del t[0]

def tail(t):
return t[1:]

a = [1,2,3]
b = [1,2,3]

print a
print a

print b
print tail(b)
print b

``````
``````

[1, 2, 3]
[2, 3]
[1, 2, 3]
[2, 3]
[1, 2, 3]

``````
``````

In [22]:

a = [1,2,3]
b = a[:]
c = list(a)
d = a + []

print a
print b
print c
print d
print a is c
del a[0]
print d

``````
``````

[1, 2, 3]
[1, 2, 3]
[1, 2, 3]
[1, 2, 3]
False
[1, 2, 3]

``````
``````

In [ ]:

``````