Python strings
Strings
String literals in python are encircled by either single quotes, or twofold quotes.
And now use print() to display output
EXAMPLE:-
- print('table')
(or)
- print("table")
Allotting a string to a variable is finished with the variable name followed by an equivalent sign and the string:-
- a = "table"
- print(a)
PYTHON STRINGS:-
Python has a worked in string class named "str" with numerous helpful highlights
String literals can be encased by either twofold or single statements, albeit
single statements are all the more ordinarily utilized. Oblique punctuation line
gets away from work the standard path inside both single and twofold cited
literals - for example \n \' \". A twofold cited string exacting can contain
single statements with no complain (for example "I didn't do it") and in like
manner single cited string can contain twofold statements. A string strict can
traverse various lines, yet there must be an oblique punctuation line \ toward
the finish of each line to escape the newline. String literals inside triple
statements, """ or ''', can traverse different lines of text.
Python string program
String1 = 'Welcome to the This World'
print("String with the utilization of Single Quotes: ")
print(String1)
# Creating a String
# with twofold Quotes
String1 = "I'm a This"
print("\nString with the utilization of Double Quotes: ")
print(String1)
# Creating a String
# with triple Quotes
String1 = '''I'm a This and I live in a universe of "This"'''
print("\nString with the utilization of Triple Quotes: ")
print(String1)
# Creating String with triple
# Quotes permits different lines
String1 = '''This
For
Life'''
print("\nCreating a multiline String: ")
print(String1)
output:
String with the use of Single Quotes:
Welcome to the This World
String with the use of Double Quotes:
I'm a This
String with the use of Triple Quotes:
I'm a This and I live in a world of "This"
Creating a multiline String:
This
For
Life
No comments