Python ProgrammingPython Programming

Python set the tab size to the specified number of whitespaces

txt = "Canada\tis\ta\tgreat\tcountry"

print(txt)
print(txt.expandtabs())
print(txt.expandtabs(2))
print(txt.expandtabs(4))
print(txt.expandtabs(10))
Output
Canada	is	a	great	country
Canada  is      a       great   country
Canada  is  a great country
Canada  is  a   great   country
Canada    is        a         great     country