Skip to content
Advertisement

Python print indentations

In Python 3.x how do you print an indent of white space, the method I am looking for looked something like this

level = 3
print ('% indent symbol' % * level, 'indented text')

should print:

            indented text

repeating answer from below: thanks to @sudo_coffee for t

print ('t' * level, 'indented text')

or maybe:

print ((' ' * 4) * level, 'indented text')

Advertisement

Answer

sorry guys, think I found the answer, thanks to @sudo_coffee for t

print ('t' * level + 'indented text')

or maybe:

print ((' ' * 4) * level + 'indented text')
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement