I am trying to multiply only certain number in a list with even index number. My list has some numbers that occur multiple times. These numbers have the same index values. However, I want to multiply those numbers by 2 only if they occur in the place such that their index number is even.
All forums I searched have the opposite of my need, where they want recurring numbers to have the same index number. For my case, I want recurring numbers to have different index values.
a = ['2', '0', '0', '1', '4', '5', '6', '4', '0', '4', '6']
my_list = []
for i in a:
if a.index(i) in [1,3,5,7,9]:
#get ascii value using ord()
a1 = (ord(i)) * 2
else:
a1 = ord(i)
my_list.append(a1)
Expected = [50, 96, 48, 98, 52, 106, 54, 106, 48, 104, 54]
Got = [50, 52, 54, 52, 52, 54]