I am new to learning python, and I only have limited programing experience, so I am sorry for asking such a basic question. I am doing an online python tutorial and wanted to take the program a bit further than the lesson requested to test out how far I could take it. The problem is that I have been hitting a roadblock. After reading a bunch of posts on here I have moved things around, changed variable names, used more functions, less functions, if else statements, and toyed around/ troubleshot, but have received all sorts of errors. I am going to paste where I currently am at below and would really appreciate if someone out there could help me finish up the program.
Here is what I would like for the program to do:
- I would like the user to be prompted to enter a number.
- I would like to make sure that the user entered a number, and if they don't I would like the program to give them an error and restart.
- I would like that once the number is received the program squares that number and then prints the answer. (again thanks much for all the help)
HERE IS WHERE I AM AT:
n1 = raw_input('Please enter your desired number:')
def n2():
n2 = n1.isnumeric()
return n2
def square(n2):
squared = n2**2
print "%d squared is %d." % (n2, squared)
return squared
square(n2)
only int
or bothint and float