Python Strings Sample Pgems
Python Strings Sample Pgems
name = "Python"
print(name)
# using + operator
result = greet + name
print(result)
H
e
l
l
o
9.Python String Length
In Python, we use the len() method to find the length of a
string. For example,
greet = 'Hello'
print(len(greet))
# count length of greet string
# Output: 5
10.Python String Formatting (f-Strings)
Python f-Strings make it really easy to print values and
variables. For example,
name = 'Cathy'
country = 'UK'