Declare string object, assign string (using different ways), and print the string in Python.
These are some of the ways to assign strings to the string object.
| Ways |
Syntax |
Description |
| Way1 |
Single quotes 'Message' |
Assign a single line string. |
| Way2 |
Double quotes "Message" |
Assign a single line string. |
| Way3 |
Triple single quotes '''Message''' |
Assign single line as well as multi-line string. |
| Way4 |
Triple double quotes """Message""" |
Assign single line as well as multi-line string.
|
Program:
Output
str1: Hello world, How are you? str2: Hello world, How are you? str3: Hello world, How are you? str4: Hello world, How are you? str5: Hello world, How are you?need an explanation for this answer? contact us directly to get an explanation for this answer