import sys

i=0;

def func1(i):
    print "i am in function func1"
    if i<5:
        i=i+1
        func1(i)
    else:
        return
    return


def main():
    print "beginnning the function\n"
    func1(i)
    print "hello Daniweb"
    s='aman'
    print "hahha"
main()

it is giving me syntax error in print "hahha" statement. WHat is that ? According to me, it is correct. can anyone help. thanks.

Edited 3 Years Ago by nitin1

I get this error:

  File "/tmp/asdf.py", line 6
    print "i am in function func1"
                                 ^
SyntaxError: invalid syntax

You should be getting the same error. What's your Python version?

how to check this thing that which version i am using ?

I got this thing after writing sys.version :

2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)]

I am doing tutorials which is teaching me python2. thanks in advance.

Why are you using Python 2.4 wish is 8 year old?
Code works for Python 2,even if there some ugly stuff in it.

Post full Traceback.

so which version i should use ? please help as i am totally new to this. thanks to you.

Use Python 2.7.5
The try to run code again.

Python 3.3.2 is also ok,but most of tutorial/books are still for python 2.
Most of us still use python 2,until most 3 party module is rewritten for python 3.

it seems you are using the new version of python .just use () around your print statements :
print(" I am in function 1")and change all your print statements the same way

it seems you are using the new version of python

No he is using Python 2.4,do you not see output from sys.version in his post?

i have installed python 2.7.5. so what is the differece between 2.7.5 and 3.3.2 ? I have seen that they both are new on their website. what is this ? thanks in advance.

Python3 is a more streamlined/modern version of Python. Python 2.7.x is the end of the Python2 line. Not all Python2 code will work with Python3, so Python 2.7 will be maintained for those folks who have a fair amount of Python2 code.

Some of the popular Python3 improvements have been ported down to Python 2.7
Sooner or later Python3 will take over, right now there is a somewhat awkward interim time.

"Dive Into Python"
Mark Pilgrim's Free online book, novice to pro, updated constantly.
rewritten for Python3 (check appendix A for 2to3 differences)
http://getpython3.com/diveintopython3/

As you well know C++ and C are still improved and newer versions appear that are not totally backward compatible.

Google Python video series:
http://code.google.com/edu/languages/index.html#_python_understanding

As you get to know Python better, you will discover a lot of modern computing concepts that C++ simply does not have.

Edited 3 Years Ago by vegaseat

should i go for python learning then ? By taking any project thing or what ? You seems to be python expert and lover. :-)

This question has already been answered. Start a new discussion instead.