Python - String Method - expandtabs() Tutorial
It will return a string, with all '\t' in a string will be replaced with whitespace characters of default size 8. we can also modify the tab size by specifying the size as a parameter in expandtabs() methods.
Syntax-
String.expandtabs(tabsize)
#tabsize - (Optional)It is a size that needs to be set for the tab.
by default, it is 8 if not specified
Example-
str1 = "He\tllo\tPy\tthon"
print(str1)
print(str1.expandtabs())
print(str1.expandtabs(2))
print(str1.expandtabs(3))
print(str1.expandtabs(5))
Output-
He llo Py thon
He llo Py thon
He llo Py thon
He llo Py thon
He llo Py thon