import random numbers = [] k = 0 for i in range(-10,10): i = random.randrange(-10,10) numbers.append(i) print(numbers) print([x * (i % 2) for i,x in enumerate(numbers)]) print([x if i % 2 else 0 for i,x in enumerate(numbers)])
Standard input is empty
[1, -8, -6, 9, -6, 9, -5, 3, -5, 6, 7, 9, -6, -1, -5, -5, 9, 9, 4, -7] [0, -8, 0, 9, 0, 9, 0, 3, 0, 6, 0, 9, 0, -1, 0, -5, 0, 9, 0, -7] [0, -8, 0, 9, 0, 9, 0, 3, 0, 6, 0, 9, 0, -1, 0, -5, 0, 9, 0, -7]