Write a python code for below problem,
We have a list
Input = [5,'Unnamed: 1','Unnamed: 2','Unnamed: 3', 6, 'Unnamed: 5','Unnamed: 6']
want to convert it into: Output= [5,5,5,5,6,6,6]
1
Expert's answer
2021-10-12T00:37:28-0400
list1 = [5,'Unnamed: 1','Unnamed: 2','Unnamed: 3', 6, 'Unnamed: 5','Unnamed: 6']
for i in range(len(list1)):
if 0 <= i <=3:
list1[i] = 5
else:
list1[i] = 6
list1
[5, 5, 5, 5, 6, 6, 6]
Comments
Leave a comment