If possible, why the code below is invalid? (to get [2,2,4,5]):
tsil=[1,2,3,4]
added=[i+1 if i!=2 else i=2 for i in tsil]
Is there an inbuilt way of leaving a certain element (ex: all the "2"s) unchanged without skipping them?
If possible, why the code below is invalid? (to get [2,2,4,5]):
tsil=[1,2,3,4]
added=[i+1 if i!=2 else i=2 for i in tsil]
Is there an inbuilt way of leaving a certain element (ex: all the "2"s) unchanged without skipping them?