Table of Contents

, , , , , , , , ,

About the Club

Python Club Topics - Exercise: Reverse name

Exercise: Reverse name

  1. Output: Display the user's name in reverse order with a comma between names
  2. What you learn from the example:
    1. Get input from a user
    2. Manipulate strings

Solution

[1] code:python show
# Prompt the user to input their first name and store it in the 'fname' variable
fname = input('Input your First Name : ')

# Prompt the user to input their last name and store it in the 'lname' variable
lname = input('Input your Last Name : ')

# Display a greeting message with the last name followed by the first name
print('Hello  ' + lname + ', ' + fname)


Bonus round: Try reversing the letters of your name.