Python String expandtabs() Method Tutorial

In this section we will learn what String expandtabs() method is and how to use it in Python.

What is String expandtabs() Method in Python?

The Python string expandtabs() method is used to set a size for tabs in the target string value (the one that invoked this method.

For example, if we want tabs in a string value to be equal to 20 white-spaces, then we can use this method and set the value 20 as its argument.

Python String expandtabs() Method Syntax:


String expandtabs() Method Parameter

The method takes one argument and that is the size of the tabs for the target string value. (This value is of type integer)

String expandtabs() Method Return Value

The method does not return a value.

Example: using string expandtabs() method in python

s1 = "My name is John Doe \tAlso my cousin's name is also the same as mine! "



My name is John Doe                    Also my cousin's name is also the same as mine!

Top Technologies