Python Forum

Full Version: Diff. between Py 2.7 and 3
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

For a while I was going mad trying to find out why the print output from the test code below using Python 2.7 had single quotes added till a ran the sketch with Python 3. Why the difference?

a = "a"
b = "b"
c = "2.5"

a = a.strip('\"')
b = b.replace('"', '').replace("'", '')
c = float(c.strip('\"'))

print (a, b, c)
output with ver. 2.7
Output:
('a', 'b', 2.5)
and with ver 3.5
Output:
a b 2.5
You are giving the print statement a tuple.