Q. Write a program to multiply an element by 2 if it is odd index for a given list containing both number and strings.


Answer :-

lst = eval (input("Enter a list :- "))

for i in range(len(lst)) :
    if i % 2 != 0 :
        lst [ i ] = lst [ i ] * 2
print(lst)


Output  :-

Enter a list :- [4,2,9,'Path',5,57,"Walla"]
[4, 4, 9, 'PathPath', 5, 114, 'Walla']
>>>

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post