my python will not run a program. it will always think that the heading is a syntax error. What can i do?
code please.
i didnt even write any code. all i entered as a test was print ('hello world') which return the syntax error and when i clicked ok to see the error it highlighted the 5 in the header that said 2.5.1
Did you make sure you commented out your header?
sadly i have no idea what that means
Put a # before any text and that makes it a comment. Comments are used for code that you want people to read and not the computer.
#hello.py # Get the user's name and print a friendly hello name = raw_input("Please enter your name ") print "Hello", name, "- good to see you!"
Don't bother with the header at first, it's only there to let the computer know which interpreter to use. Unless you have a Python3 interpreter as the default, which is unlikely, it'll just use whatever you have set up, probably Python2.6 or 7 anyway. You can always specify an interpreter at the command line. python2 ~/scripts/myapp.py By the way, unless you've done from __future__ import print_function you shouldn't add parenthesis to your print statements. print('hello world') means print a tuple containing one object, the string 'hello world'. It should print ('hello world') In Python2 we just do print 'hello world' Note, print is a keyword in P2, but a function in P3 so print('hello world') in P3 does actually mean print the string 'hello world' (by calling the print function on it).
Join our real-time social learning platform and learn together with your friends!