[]
Season 02 - Introduction to Python Programming
LISTS & TUPLES
var = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
print(var[0])
print(type(var[0]))
print(var[0][0])
print(type(var[0][0]))
[1, 2, 3]
<class 'list'>
1
<class 'int'>
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-14-1576e7398292> in <cell line: 1>() ----> 1 [1] + 5 TypeError: can only concatenate list (not "int") to list
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-20-a8f23cb03114> in <cell line: 1>() ----> 1 [1,2,3] - [1] TypeError: unsupported operand type(s) for -: 'list' and 'list'
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-21-cc54057e2956> in <cell line: 1>() ----> 1 [1,2,3] * [1] TypeError: can't multiply sequence by non-int of type 'list'
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-22-14e8234bade6> in <cell line: 1>() ----> 1 [1,2,3] / [1] TypeError: unsupported operand type(s) for /: 'list' and 'list'
<class 'list'>
<class 'tuple'>
<class 'tuple'>
<class 'list'>
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-65-4d24914f4c1c> in <cell line: 2>() 1 var = (1,2,3) ----> 2 var[0] = 10 TypeError: 'tuple' object does not support item assignment