[Solved] Hackerrank doesn’t accept my code. Why?


Firstly, You should not write in range(0,5) if you want to iterate through n numbers.

Secondly, You do not need to write another while function. You use for loop or while loop for this question.

Change

for i in range(0,5):
    while i < 5:
        print(i ** 2)
        i += 1
        break

to

for i in range(0,n):
    print(i ** 2)

2

solved Hackerrank doesn’t accept my code. Why?