-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
648f73b
commit 509f874
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#list methods example | ||
names=["sanjana","hrishita","shruti","manish","kamlesh"] | ||
print(names) | ||
|
||
#adding/appending new item | ||
names.append("ram") | ||
print(names) | ||
|
||
#returning no of occurance of given item | ||
print(names.count("kamlesh") ) | ||
|
||
#returns an index of given of given item | ||
print(names.index("manish") ) | ||
|
||
#extending a list | ||
names.extend(["jadu","dada"]) | ||
print (names) | ||
|
||
#inserting an item at given index | ||
names.insert(2,"sonu") | ||
print(names) | ||
|
||
#removing an item from given item | ||
names.pop() | ||
print(names) | ||
|
||
#removing a given item | ||
names.remove("manish") | ||
print (names) | ||
|
||
#reversing a list | ||
names.reverse() | ||
print(names) | ||
|
||
#sorting a list in given order | ||
names.sort(reverse=True) | ||
print(names) | ||
|
||
#copying a list | ||
print(names.copy() ) | ||
|