0

How to change list name in for loop at every iteration

If eg list are col1=[] , col2=[] , col3=[] ,col4=[] and for loop is there which will run for 4 time . for i in range (1,5): col1=5 At next i=2 it should be col2=5, At next i=3 it should be col3=5, At next i=4 it should be col4=5 It means here I want to use different list at every iteration

9th May 2022, 2:13 AM
Neha Sharma
1 ответ
+ 3
Neha Sharma 👇👇 col1 = [] col2 = [] col3 = [] col4 = [] # fill all the list inside a list col= [col1, col2, col3, col4] for i in range(4): col[i].append(5) print(col1, col2, col3, col4) https://code.sololearn.com/czThPcnw6G7h/?ref=app
9th May 2022, 2:25 AM
NonStop CODING
NonStop CODING - avatar