I'm learning Liste / Matrice in Python and I would like to make some addition in Liste. Let me explain, in the exemple, in the Table "exam_liste" the second position (1 in python) I want to add +2 and refresh the table, I don't want to insert anything, I want to make an addition directly in the Liste and in my exemple it doesn't working.
Anyone can explain me this ?
ote = 1
exam_liste = [None] * 5
print(exam_liste)
exam_liste.insert(1,note)
print(exam_liste)
exam_liste.insert(1,exam_liste[1]+2)
print(exam_liste)
>>> [None, None, None, None, None]
>>> [None, 1, None, None, None, None]
>>> [None, 3, 1, None, None, None, None]
I was waiting like : [None, 3, None, None, None, None, None]
map(lambda x: x if x is None else x + 2, list). Or just use list[index] += value