File tree 1 file changed +8
-0
lines changed
1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 1
1
if __name__ == '__main__' :
2
+ # take input as a number
2
3
N = int (input ())
4
+ # define two lists
3
5
z = []
4
6
l = []
5
7
for i in range (N ):
8
+ # add some input to the end of list z
6
9
z .append (input ())
7
10
for x in z :
8
11
y = x .split ()
9
12
if y [0 ]== 'insert' :
13
+ # insert the secound argument at the index of the secound argument
10
14
l .insert (int (y [1 ]),int (y [2 ]))
11
15
if y [0 ]== 'append' :
16
+ # add to the end of the list
12
17
l .append (int (y [1 ]))
13
18
if y [0 ]== 'remove' :
14
19
try :
20
+ # removes the first item from the list that equaled int(y[1])
15
21
l .remove (int (y [1 ]))
16
22
except :
17
23
pass
20
26
if y [0 ]== 'sort' :
21
27
l .sort ()
22
28
if y [0 ]== 'reverse' :
29
+ # reverse the order of the list
23
30
l .reverse ()
24
31
if y [0 ]== 'pop' :
25
32
try :
33
+ # delete the last item
26
34
l .pop ()
27
35
except :
28
36
pass
You can’t perform that action at this time.
0 commit comments