Manipulating lists Flashcards

1
Q

updating element in index 1 with value xxx

A

L[1]= xxx

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

add one element xxx to end of list L (2 modi)

A

L2= L+ [xxx]

L.append (xxx)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

add one element xxx to start of list L

A

L2= [xxx] + L

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

updating more than one element (two elements x and y) to indexes 1 and 3

A

L[ 1: 3 ]=[ x , y]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

add element xxx at specific index i

A

list.insert ( i , xxx )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

remove element in index i

A

del (L [i] )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

remove value xxx from list L

A

L . remove (xxx)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

copy list L

A

L2=L1.copy ()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

look for index of item xxx in L

A

L.index (xxx)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly