Skip to content

Commit 028fb51

Browse files
Merge pull request keshavsingh4522#144 from Isaiah08-D/patch-1
Add comments to list/list_01.py
2 parents a95f3fa + cd0e815 commit 028fb51

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: list/list_01.py

+8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
if __name__ == '__main__':
2+
# take input as a number
23
N = int(input())
4+
# define two lists
35
z=[]
46
l=[]
57
for i in range(N):
8+
# add some input to the end of list z
69
z.append(input())
710
for x in z:
811
y=x.split()
912
if y[0]=='insert':
13+
# insert the secound argument at the index of the secound argument
1014
l.insert(int(y[1]),int(y[2]))
1115
if y[0]=='append':
16+
# add to the end of the list
1217
l.append(int(y[1]))
1318
if y[0]=='remove':
1419
try:
20+
# removes the first item from the list that equaled int(y[1])
1521
l.remove(int(y[1]))
1622
except:
1723
pass
@@ -20,9 +26,11 @@
2026
if y[0]=='sort':
2127
l.sort()
2228
if y[0]=='reverse':
29+
# reverse the order of the list
2330
l.reverse()
2431
if y[0]=='pop':
2532
try:
33+
# delete the last item
2634
l.pop()
2735
except:
2836
pass

0 commit comments

Comments
 (0)