What is Wrong With My Code?( To print squares of all whole number till the user given number)


n = int(input())
c = 0
if (c<=n):
print (c*c)


That line implies a loop but there is none present.

If you are doing a track exercise, then it should be raw_input(), not input() since the course is written in Python 2.7.x, not Python 3.

It is always advisable to give the user some indication of the expected input…

n = int(raw_input("Enter a number: ")


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.