I have to take input of an integer and then print the squares of all natural numbers upto that number.
I am doing following:
x=input("enter the integer")
for i in range(1,x):
print(i*i)
I am getting errors in it. please help
>Solution :
Whenever you take input in python it treats it as a string not int, so you need to specify that in code, also you have range from (1,x); it will exclude x hence take x+1
x=int(input("enter the integer"))
for i in range(1,x+1):
print(i*i)
please let me know if it worked properly