Combine Strings
Create two variables: first_name = "John" last_name = "Doe" Combine them into full_name with a space between. Display: John Doe
Strings are text enclosed in quotes.
You can combine (concatenate) strings with +:
first = "Hello"
second = "World"
message = first + " " + second
print(message) # Hello World
You can also repeat strings with *:
print("Ha" * 3) # HaHaHa
Create two variables: first_name = "John" last_name = "Doe" Combine them into full_name with a space between. Display: John Doe
Display "Ho" repeated 3 times. Output should be: HoHoHo
The + sign glues strings together exactly as they are: Python adds nothing between them, not even a space. Change the code so it shows Hello, Bob! - with a…
Create a variable name = "Alice". Display: Hello, Alice! Hint: You need to combine "Hello, " + name + "!"
Learn to work with text (strings) in Python.
This lesson has 4 exercises.
No. The code is written and run in the browser.