To print on the same line
Python2 uses
print item,
Python3 uses
print(item, end=' ')

Is there a way to make it work in both versions?

from __future__ import print_function
item1, item2 = 'abc', 'def'
print(item1, end='')
print(item2)
commented: thanks +10

Or you can do this:

import sys

def myprint(item):
    '''
    print items on the same line
    works with Python2 and Python3 versions
    '''
    sys.stdout.write(str(item))
    sys.stdout.flush()

for x in range(10):
    myprint(x)

'''result -->
0123456789
'''
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.