152k views
3 votes
Write a program that reads a person's first and last names, separated by a space. Then the program outputs last name, comma, first name. End with newline. Example output if the input is: Maya Jones

User Derhansen
by
7.7k points

1 Answer

2 votes

In pyton:

name = input("What is your name? ")

lst = name.split()

print(f"{lst[-1]}, {lst[0]}")

I hope this helps!

User Joshua LI
by
8.6k points