-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistbasis.py
57 lines (49 loc) · 895 Bytes
/
listbasis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
print("LISTS")
x = list()
print("empty list():", x)
x = ("this", "were", "be", "a", "tuple")
print("parse a tuple")
print(x)
x = list(x)
print(x)
print("List comprenhension:")
x = [par for par in range(100) if par%2 == 0]
print(x)
print("delete list elements")
del(x[10:])
print(x)
print("Append element")
x.append(100)
print(x)
print("Extend using for merge lists")
x = [1,3,5]
y = [100,430,213]
print(x)
print(y)
x.extend(y)
print(x)
y.extend(x)
print(y)
print("Insert element at given index")
x = [1,3,5,7]
print(x)
x.insert(2,[2,4,6])
print(x)
print("Pop last elment of list")
e = x.pop()
print(e)
print("Remove the first instance of an item")
x.remove(3)
print("Sort in place items")
x = [9,12,3,12,4,2,54,7,4,2]
print(x)
x.sort()
print(x)
print("Reversse order in list in place")
x.reverse()
print(x)
x.sort()
print(x)
print("Reversing sort in place")
x.sort(reverse=True)
print(x)