EN
Python - assign string to variable
0 points
In this article, we would like to show you how to assign string to a variable in Python.
Quick solution:
xxxxxxxxxx
1
my_string = 'ABC'
2
print(my_string)
In this example, we use single quotation marks (''
) to assign string to a variable in Python. You can also use double quotation marks (""
).
xxxxxxxxxx
1
my_string = 'ABC'
2
print(my_string)
Output:
xxxxxxxxxx
1
ABC
In this example, we use three single quotation marks to assign string to a variable in Python. You can also use three double quotation marks.
xxxxxxxxxx
1
my_string = '''line1
2
line2
3
line3'''
4
5
print(my_string)
Output:
xxxxxxxxxx
1
line1
2
line2
3
line3