I am trying this, where i is an integer:
sys.stdout.write('\thello world %d.\n' % i+1)
and it says "cannot concatenate str and int". I have tried various combinations:
int(i) + 1
i + int(1)
... but it's not working
str.format is preferred if your Python version is new enough to support it (Python2.6+)† see that you don't even need to worry about the precedence of % and + here.
sys.stdout.write('\thello world {}.\n'.format(i+1))
or as the title of the question suggests - using a print statement
print '\thello world {}.'.format(i+1)
In Python3, print is a function, so you need to call it like this
print('\thello world {}.'.format(i+1))
† In Python2.6 you need to use {0} in stead of plain {}