Python

Python Menu

Python

Python String expandtabs() - Definition, Syntax, Parameters, Examples

Definition

The expandtabs() method sets the tab size to the specified number of whitespaces.

Syntax

string.expandtabs(size)

Parameters

Parameter Description
size Optional. A number specifying the tabsize. Default tabsize is 8

Examples:

testStr = "H\te\tl\tl\to" x = testStr.expandtabs() y = testStr.expandtabs(2) z = testStr.expandtabs(3) print(x) print(y) print(z)

Introduction

Python Basics

Python Advance

Data Science Python Tutorials

Python Functions and Methods