Search code examples
pythonstringprinting

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')

Solution

  • 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')