2.2 Strings

Topic

2.2 Strings

Topic Progress:

A string in python is denoted by quotation marks, they can be single or double quotes like the example below.

‘This is a string’
“This is also a string”

You can also assign a string to a variable,

A = “This is a string”
B = “12”

And display it with print()
print(“My age is:  ”)
print(B)

Output:
My age is 12

Why don’t we just code print(“My age is: ” + B)?
In this case, we could code like this because they are both strings. But you’ll have to be careful not to do this with different data types, which is the next topic!

@

Not recently active