import random l = [random.choice(range(-20,20)) for i in range(20)] positive = [] negative = [] for i, v in enumerate(l): ([positive, negative][v < 0]).append(i) print(l) print(positive) print(negative)
Standard input is empty
[-5, 15, -20, -6, -14, 16, 18, -20, 7, 4, 17, 0, -4, -5, -14, -12, -10, 3, -12, -14] [1, 5, 6, 8, 9, 10, 11, 17] [0, 2, 3, 4, 7, 12, 13, 14, 15, 16, 18, 19]