2014-05-10 15:23:00 -04:00
|
|
|
# test slices; only 2 argument version supported by Micro Python at the moment
|
|
|
|
x = list(range(10))
|
|
|
|
|
|
|
|
# Assignment
|
|
|
|
l = list(x)
|
|
|
|
l[1:3] = [10, 20]
|
|
|
|
print(l)
|
|
|
|
l = list(x)
|
|
|
|
l[1:3] = [10]
|
|
|
|
print(l)
|
|
|
|
l = list(x)
|
|
|
|
l[1:3] = []
|
|
|
|
print(l)
|
2014-05-10 16:03:30 -04:00
|
|
|
l = list(x)
|
|
|
|
del l[1:3]
|
|
|
|
print(l)
|
2014-05-10 15:23:00 -04:00
|
|
|
|
|
|
|
l = list(x)
|
|
|
|
l[:3] = [10, 20]
|
|
|
|
print(l)
|
|
|
|
l = list(x)
|
|
|
|
l[:3] = []
|
|
|
|
print(l)
|
2014-05-10 16:03:30 -04:00
|
|
|
l = list(x)
|
|
|
|
del l[:3]
|
|
|
|
print(l)
|
2014-05-10 15:23:00 -04:00
|
|
|
|
|
|
|
l = list(x)
|
|
|
|
l[:-3] = [10, 20]
|
|
|
|
print(l)
|
|
|
|
l = list(x)
|
|
|
|
l[:-3] = []
|
|
|
|
print(l)
|
2014-05-10 16:03:30 -04:00
|
|
|
l = list(x)
|
|
|
|
del l[:-3]
|
|
|
|
print(l)
|