Solution: Concatenating Strings

Review the solution to the challenge.

We'll cover the following

Solution

  1. Ask the user for their first and last name. Store the value entered by the user in a variable called firstName and lastName, respectively.
firstName = user_input first name
lastName = user_input last name
  1. Concatenate the firstName and lastName variables with the greeting message "Hello, " and an exclamation point using the string concatenation operator +. Store the result in a variable called greeting.
greeting = "Hello, " + firstName + " " + lastName + "!"
  1. Concatenate the lastName variable with the message "How are you doing" and a question mark using the string concatenation operator +. Store the result in a variable called inquiring_health.
inquiring_health = "How are you doing " + lastName + "?"
  1. Finally, print the greeting and inquiring_health variables.
print greeting
print inquiring health

Below is the complete pseudocode for this challenge:

Get hands-on with 1200+ tech skills courses.