Re: [Tutor] Calling a function does not return what I want it to return

2012-07-19 Thread Alexander Q.
On Thu, Jul 19, 2012 at 4:21 PM, Dave Angel wrote: > On 07/19/2012 06:58 PM, Alexander Q. wrote: > > I have this little program that is supposed to calculate how many > diagonals > > a polygon of x sides has, but it does not return what I have in the > > "return" part of the function when I call

Re: [Tutor] Calling a function does not return what I want it to return

2012-07-19 Thread Alan Gauld
On 20/07/12 00:17, Prasad, Ramit wrote: def num_diag(var): ans = 0 if var <= 3: print("No diagonals.") else: for i in range(num_sides - 3): ans = ans + i return (((var - 3)*2) + ans) num_sides = (int(raw_input("Enter sides: "))) num_diag(num_sides) NameError:

Re: [Tutor] Calling a function does not return what I want it to return

2012-07-19 Thread Dave Angel
On 07/19/2012 06:58 PM, Alexander Q. wrote: > I have this little program that is supposed to calculate how many diagonals > a polygon of x sides has, but it does not return what I have in the > "return" part of the function when I call it. Here is the code: > > def num_diag(var): > ans = 0 > if

Re: [Tutor] Calling a function does not return what I want it to return

2012-07-19 Thread Emile van Sebille
On 7/19/2012 3:58 PM Alexander Q. said... I have this little program that is supposed to calculate how many diagonals a polygon of x sides has, but it does not return what I have in the "return" part of the function when I call it. Here is the code: def num_diag(var): ans = 0 if var <= 3:

Re: [Tutor] Calling a function does not return what I want it to return

2012-07-19 Thread Prasad, Ramit
> I have this little program that is supposed to calculate how many diagonals a > polygon of x sides has, but it does not return what I have in the "return" > part of the function when I call it. Here is the code: > > def num_diag(var): > ans = 0 > if var <= 3: > print("No diagonals.") >

[Tutor] Calling a function does not return what I want it to return

2012-07-19 Thread Alexander Q.
I have this little program that is supposed to calculate how many diagonals a polygon of x sides has, but it does not return what I have in the "return" part of the function when I call it. Here is the code: def num_diag(var): ans = 0 if var <= 3: print("No diagonals.") else: for i i