Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 1156  / 2 Years ago, thu, february 24, 2022, 9:31:53

I used the synaptic package manager to download the following:



python(was already installed), libpython3.2, python3.2-dbg, idle-python3.2, '
python3.2- minimal(was already installed)



When I run the IDLE I type a simple line like
print "some sample text"



And I get a syntax error.
Can someone tell me what I'm doing wrong?



Python 3.2.3 (default, Oct 19 2012, 20:13:42) 
[GCC 4.6.3] on linux2
Type "copyright", "credits" or "license()" for more information.
==== No Subprocess ====
>>> print "some sample text"
SyntaxError: invalid syntax
>>>

More From » python

 Answers
2

Actually, there's nothing wrong with the package you installed, you are trying to use python 3, check the what's new page to see the differences, one of them is that:



The print statement has been replaced with a print() function, with keyword arguments to replace most of the special syntax of the old print statement (PEP 3105). Examples:


Old: print "The answer is", 2*2
New: print("The answer is", 2*2)

Old: print x, # Trailing comma suppresses newline
New: print(x, end=" ") # Appends a space instead of a newline

Old: print # Prints a newline
New: print() # You must call the function!

Old: print >>sys.stderr, "fatal error"
New: print("fatal error", file=sys.stderr)

Old: print (x, y) # prints repr((x, y))
New: print((x, y)) # Not the same as print(x, y)!


[#34416] Friday, February 25, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
odenanno

Total Points: 207
Total Questions: 113
Total Answers: 94

Location: South Korea
Member since Sat, Oct 2, 2021
3 Years ago
odenanno questions
;