Σ.Μ. Κεφ8 positives, negatives
Τι θα εμφανίσει;
numbers = [20, -4, 7, 8, -2, -6, 1, -10]
positives = []
negatives = []
for number in numbers:
if number > 0:
positive.append(number)
else:
negatives.append(number)
print positives
print negatives
[20, 7, 8, 1] [-4, -2, -6, -10] | |
[20, -4, 7, 8, -2, -6, 1, -10] [20, -4, 7, 8, -2, -6, 1, -10] | |
[-4, -2, -6, -10] [20, 7, 8, 1]
|