-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListFunctions.py
More file actions
49 lines (37 loc) · 899 Bytes
/
ListFunctions.py
File metadata and controls
49 lines (37 loc) · 899 Bytes
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
friends = ['Souvik','Animesh','Prince','Tamoghono']
lucky_numbers = [1,2,3,4,5,6,7,8,9,10]
print(friends)
#Extending the friends list
friends.extend(lucky_numbers)
print(friends)
#Adding individual elements to list
friends.append("Anurag")
print(friends)
#Adding individual element at specific position
friends.insert(1,"Mridul")
print(friends)
#To remove element
friends.remove("Mridul")
print(friends)
#Pop
friends.pop()
print(friends)
#Find element
print(friends.index("Animesh")) #Returns Index
#print(friends.index("Mike")) --> Returns Value Error as mike is not present in the list
#Count of element
print(friends.count("Souvik"))
#Sort
#friends.sort() --> Works only for uni-type data list
print(friends)
#Reverse
friends.reverse()
print(friends)
#Copy
friends2 = friends[2:]
friends3 = friends.copy()
print(friends2)
print(friends3)
#To clear list
friends.clear()
print(friends)