Python String expandtabs() MethodLast Updated : 29 Dec 2025 Python expandstabs() method replaces all the characters by sepecified spaces. By default a single tab expands to 8 spaces which can be overridden according to the requirement. We can pass 1, 2, 4 and more to the method which will replace tab by the these number of space characters. Python String expandtabs() Method SyntaxIt has the following syntax: Parameters
Return TypeIt returns a modified string. Different Examples for Python String expandtabs() MethodLet's see some examples to understand the expandtabs() method. Python String expandtabs() Method Example 1Calling method without specifying spaces. It sets to it's default value. Output: Welcome to the Tpointtech. Python String expandtabs() Method Example 2See, how the output is changing after each call. Each method is set to different-different number of spaces. Output: Welcome to the Tpointtech. Welcome to the Tpointtech. Welcome to the Tpointtech. Next TopicPython Strings |
We request you to subscribe our newsletter for upcoming updates.