Concatenating strings with compound addition #
As we can increase the value of the number by using the += operator, we could use the same operator to concatenate strings together, like so:
full_name = ""
full_name += "Fistname" # Equivalent to full_name = full_name + "Firstname"
full_name += " "
full_name += "Lastname"
print(full_name) # Output: Firstname Lastname
Exercise #
- Create a variable
full_nameby combining your first and last name together - Use the
+=operator to combine those strings - Make sure that there is a space between your first and last name
Getting Started with Python
Data Types
Python Functions
Statements in Python
Basic Debugging in Python
Basic Algorithm
Object-Oriented Programming
Error Handling
Intermediate Algorithm
Python Modules