Python Strings


Python strings are Textual data enclosed in single/double quotes.

String are denoted by Single quotation marks like text_single = 'Hello, world!'

Double quotation mark like text_double = "Python is awesome!" where text_single and text_double are python variables.


text_single = 'Hello, world!'
text_double = "Python is awesome!"

print(text_single)
print(text_double)


Single and double quote in each other :-

If you want to put a single quote inside a sentence that's already in single quotes, or a double quote inside a sentence that's already in double quotes, you can do like below examples

single_within_double = "He said, 'Python is fun!' " # Notice Single quote
double_within_single = 'She exclaimed, "I love coding!" ' # Notice Double quote

print(single_within_double)
print(double_within_single)


Python Tripple Quote Strings :-

Using triple quotes allows you to create strings that span multiple lines without needing to use escape characters like \n. Remember you can use """ or ''' quotes to create triple or multiline quote strings.

try to replace single qute to double quote in playground.

multi_line_string = '''
This is a multi-line string using triple quotes.
It can span across multiple lines easily.
'''
print(multi_line_string)