Consider this simple python:
def cube(x):
return x*x*x;
if __name__ == '__main__':
print(cube(4));
Works ok. But when I open up the python command line interpreter and do:
>>> def cube(x): return x*x*x;
... cube(4);
I get:
File "<stdin>", line 2
cube(4);
^
SyntaxEror: invalid syntax
What stupid thing are my doing wrong?
Try pressing enter one more time :) The ellipse in front of your cube(4)
indicates that you are still defining your function. Also, you can remove the semicolon:
>>> def cube(x): return x*x*x
...
>>> cube(4)
64
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With