Answer to Question #249862 in Python for Srinivasa Reddy

Question #249862
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]

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS