expandtabs() String Method in Python with Examples

expandtabs() method returns a copy of string where all tab characters are expanded using number of spaces given in argument tabsize = integer_number.

Syntax: expandtabs() String Method


Example: expandtabs() String Method

message = '\tWelcome to Python !'

Note: here \t is TAB and also known as escape sequence.


Welcome to Python withot TAB!
	Welcome to Python with TAB!
                Welcome to Python with TAB!

Compare above three results to understand it properly & notice the gap in the begining of the output string :)

Related String Methods