Strings and Characters

0

Creating Strings

  • We can create a string in Python by assigning a group of characters to a variable. The group of characters should be enclosed inside single quotes or double quotes.

                   s = 'Welcome to Programmer Fect'

                   s1 = "Welcome to Programmer Fect"



Length of a String

  • Length of a string represents the number of characters in a string.

  • To know the length a string, we can use the len( ) function.

  • This function gives the number of characters including spaces in the string.

 

Escape Characters and their Meanings 

Escape Character                Meaning

\a                                               Bell or alert

\b                                               Backspace

\n                                               New line

\t                                                Horizontal tab space

\v                                               Vertical tab space

\r                                                Enter button

\x                                               Character x

\\                                                Displays single \

Tags

Post a Comment

0Comments
Post a Comment (0)