Sequences
Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
x = [1.1, 2, [3, 'tomato', 4], 'cat']
x[2]
tuple(x[-1]) == ("cat",)
type(x[-1]) == str and isinstance(x[0], (int, float))
x[2][-1]
x[4]
len(x[-1])
[1, 2] + x[1]
[1,2] + [3, x[1]]
"na"*4 + " batman"
(4, 7, 5) == [4, 7, 5]
(4, 7, 5)[0] == [4, 7, 5][0]
'tomato' in x
str(x[0])
x[:2] + x[-1]
x[-1].replace('c', 'b')
list(x[-1].upper())
Back to exercises