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


#1

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


#2

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: ")

#3

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