What does \t do in Python? Full Explanation

Published by Ubaid Khan on

 

\t is called the reserved symbol in python and is used for TAB character. It means that the program uses it in the program it makes a horizontal Tab space between two strings or characters. Shortly it is a tab character.

Example:

Print (“python \t program”)

It gives us the output: python program (one tab space between python and program string)

In the string, the programmer can add operators like \t anywhere you like.

There are also others which are given below.

\n = linefeed (prints the stuff after this on the next line)
\r = carriage return (basically also used for printing stuff on the next line)
\’ = print a single quote ( ‘ ) in your text
\” = print a double quote ( “ ) in your text
\\ = print a backslash ( \ ) in your text

There are some special characters known as metacharacters, these characters are not language specific characters but these are known as the metacharacters of Regular expressions. These are the following

\t – Tab

\n – New Line

\s – Blank Space


Ubaid Khan

hello friends, we are teh team of engineers and blogging is our passion. our team consists of Tariq Naveed, Izhar, and Ubaid