# [SOLVED] Python : Syntax error help



## ajainakp (Mar 25, 2011)

I am trying to run a simple class program in python
but it stuck with a Error: "Invalid Syntax" since
the error is not informative, Expecting a good
help.


Code I tried follows:
----------------
class FirstClass():
def withdraw():
print 'Testing the first program'
my_account = FirstClass()
my_account.withdraw()


----------



## reventon (Oct 16, 2009)

*Re: Python : Syntax error help*

Hi,

I added the bit in bold, made sure that the code was indented properly and it works for me:

```
[font=lucida console]
class FirstClass():
    def withdraw([B]self[/B]):
        print 'Testing the first program'

my_account = FirstClass()
my_account.withdraw() 
[/font]
```
More information about "self" - The self


----------



## ajainakp (Mar 25, 2011)

*Re: Python : Syntax error help*

Thanks you so much for the help.:wave:


I copied and pasted your code as it is but still it is not
working, even I tried to adjust the indent spacing many times but invalid syntax error is keep on coimg
I dont understand the "Indet" rules and syantax
I am using python 2.3


----------



## reventon (Oct 16, 2009)

*Re: Python : Syntax error help*










Check that your indents look like the above (ignore the colours, they are added automatically by my IDE and don't matter).


----------



## ajainakp (Mar 25, 2011)

*Re: Python : Syntax error help*

View attachment Python Error.bmp


Thanks for all your instant replays...
I think I have done the same what you instructed but still the error comes
Please look at the image attachment of the error. I hope the attachment is taged properly
please get me back if you dont find the image (Python Error.bmp)
waiting your reply at the earliest.


----------



## reventon (Oct 16, 2009)

*Re: Python : Syntax error help*

I tried in the development environment that you are using:









As you can see, it works fine.

My suggestion is to update to the latest 2.x series release of Python - Python 2.7.1 Release

Or even the 3.x series if you desire - Python 3.2 Release (read this for more information - Python2orPython3 - PythonInfo Wiki)


----------



## ajainakp (Mar 25, 2011)

*Re: Python : Syntax error help*

Hi Reventon,

Thank you so much for your help it was really useful to me.ray:


----------

