# What do I do wrong?

#1

The output of this code is memory error. I`ve tried different examples of the code and find out that the problem is in loop in the loop. I want this loop to decrease a by 1 after a becomes 10. But it doesn`t work I can`t understand why?.

``````Replace this line with your code.
is_56 = []
c=0
for a in range(10):
a+=1
lis_56.append(a)
if a == 10:
for a in lis_56:
a -=1
lis_56.append(a)
else:
print lis_56

print lis_56``````

#2

Why this line? The `for` loop is incrementing it.

#3

hah, I understood: when a becomes 10, the second loop decrease every element by one and the first work once more. It`s an infinite loop. Am I right?

#4

That is what I thought you were trying to do. It's tricky getting a range based loop to go in both directions. That is where `while` comes in. We can dicker with the iterator variable and the direction.

``````a = 1
z = 1
u = []

while a > 0:
u.append(a)
if a == 10:
z = -1
a += z

print u    # [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]``````