I need to be able to multiply every second number in the list by 2, so say:
List = [1,2,3,4]
I want this to return [1,4,3,8], but all the ways I tried, for example
credit_card = [int(x) for x in input().split()]
credit_card[::2] = [x*2 for x in credit_card[::2]]
print(credit_card)
If I enter the same list from before it returns [2,2,6,4]
Is there a way to accomplish what I'm trying to accomplish?
source
share