1. Description of the expandtabs() method
The expandtabs() method returns a copy of the string with all tab characters 't' replaced by space characters a number of times equal to the tabsize parameter chosen in options.
2. Syntax & Example of the expandtabs() method
Syntax
# expandtabs() by default
string.expandtabs()
# expandtabs() with option
string. expandtabs(tabsize = value)
# or simply
string.expandtabs(value)
Example
# expand default tab
str1 = "PythontProgramming" # displays: 'Python Programming'
print(str1)
# expand default tab
str2 = "PythontProgramming" # displays: 'Python Programming'
print(str2.expandtabs())
# expand custom tab
str3 = "PythontProgramming"
print(str3.expandtabs(12)) # displays: 'Python Programming'
print(str3.expandtabs(18)) # displays: 'Python Programming'
Younes Derfoufi
my-courses.net
my-courses.net