Python string handling with example
In this tutorial , we will discuss the python string handling with example.
A string is a set of characters inorder. E.g. a letter, number and symbol may become a character.
We can print a string many way using single quote , double quote and triple quote in python.
1. print(‘hello’) //print using with single quote
2. print(“hello”) // print using with double quotes
3. print(”’hello”’) //print using with triple- single quotes
4. print(“””hello”””) // print using with triple – double quotes
Output here
We can print a string using single quote with variable.
5. first_string=’hello’ // assign a string to variable using single quote
print(first_string) // print string with variable
We can print a string using double quote with variable.
6. second_string=”hello” // assign a string to variable using double quote
print(second_string) // print string with variable
We can print a string using triple – single quote with variable
7. third_string=”’hello”’ // assing a string to variable using triple – single quote
print(third_string) // print string with variable
We can print a string using triple – double quote with variable
8. forth_string=”””hello””” // assing a string to variable using triple – double quote
print(forth_string) // print string with variable
Table of Contents
We can use the triple quote to print multiple line string
multiple_line_string=”’hello
how
are
you”’ // assing a string to variable using triple – single quote
print(multiple_line_string) // print string with variable
2. using triple – single quote to print multiple line string
multiple_line_string=”””hello
how
are
you””” // assing a string to variable using triple – single quote
print(multiple_line_string) // print string with variable
Code