Elvis
Elvis

Reputation: 11

Python return statement wont work?

def savings (pocket_money, paper_route, spending):

--- return pocket_money + paper_route - spending

print (savings (10, 10, 5))

This code says that there is a syntax error where print is. Idk whats wrong, i got that code from a beginner to python book. I tried several more examples from the book that involve the return statement, and all gave me a syntax error where print is. One thing I noticed was that when I press ENTER on the return statement the cursor appears with no spaces, as in ending the block. Idk if this is normal; I just started learning python a few days ago.

I am using Python 3.4.1

Assuming the coordinate transformations that I posted previously, would I then have to split up the integral into two parts like the following \int_0^$u_2$(\frac{$v_3$-$v_2$}{$u_3$-$u_2$})$u^2$du + \int_$u_2$^$u_3$[(\frac{$v_3$-$v_2$}{$u_3$-$u_2$})u + $v_3$ -(\frac{$v_3$-$v_2$}{$u_3$-$u_2$})$u_3$]u du ?

Upvotes: 0

Views: 901

Answers (2)

Red Cricket
Red Cricket

Reputation: 10470

Here's what I get

$ python -V
Python 2.7.3
$ python
>>> def s(pm,pr,s):
...    return pm+pr-s
...
>>> print s(10,10,5)
15
>>> def s(pm,pr,s):
...    return pm+pr-s
... print s(10,10,5)
  File "<stdin>", line 3
    print s(10,10,5)
        ^

are you sure you are putting the blank line after defining your function?

Upvotes: 0

NuclearPeon
NuclearPeon

Reputation: 6049

I put this into my interpreter and it worked fine:

>>> def savings (pocket_money, paper_route, spending):                                                                                                                                                
...     return pocket_money + paper_route - spending                                                                                                                                            
... 
>>> print (savings (10, 10, 5))
15 

Tested using python 3.3.5 and python 3.4.0

Is there another interpreter you can use? Are your parameters all numbers? Do NOT use tabs.

Upvotes: 1

Related Questions