Search code examples
pythonlistwhile-loopindentation

the problem statement but I don't know what exactly is indented


Increment the variable num by 1 post checking the above condition. (note that this increment will be outside the if statement, take care of the indentation in order to avoid a scenario of infinite loop)

this is the problem statement but I don't know what exactly is indented

I don't know if its correct or not

num = 1
factors=[ ]

while num <= 100: 

    if (num % 10) == 0 :

    factors.append(num)

    num += 1 

    print(factors)

Solution

  • I think this is the answer to your question

    num = 1
    factors = []
    while num <= 100:
        if (num % 10) == 0:
            factors.append(num)
        num += 1
    print (factors)