[Tutor] Replace nth item with single value in each nested list

EK Esawi ekesawi at yahoo.com
Fri May 15 02:26:07 EDT 2020


Hi All--


Thank you all for your input. It’s highly appreciated. With your help, I managed to produce something that works for me; but only works for nested lists with two entries. For more than two entire nested lists, it produces only 2 entries nested lists.

Here is my formula:

aa=[[x[0],60] if x[1] >= 3 else [x[0],x[1]] for x in a]

a is my list

 

Thanks again and have a nice weekend--EK


More information about the Tutor mailing list