Python strings

String

A string is a collection of characters wrapped in a single or double quote. Like many other popular programming languages, strings in Python are arrays of bytes representing Unicode characters.

first_name = "John"
last_name = "Doe"

# String formating patterns (Different ways to format your python strings)
full_name1 = first_name + " " + last_name
full_name2 = f'{first_name} {last_name}'
full_name3 = '{} {}'.format(first_name, last_name)

print(full_name1) # print the value of full_name1
print(full_name2) # print the value of full_name2
print(full_name3) # print the value of full_name3

Last updated