Using an input to prompt the user, how can I reverse the first and last names, capitalize the first letter and add a comma without using a compound condition? I was able to reverse it and add a comma. The problem is I don’t want that last comma.
names=input('What is your name:').split()
for names in reversed(names):
print(names.capitalize + ',', end=' ')
Result is this:
What is your name:steve smith
Smith, Steve,
>Solution :
Do something like this:
names = input("What is your name: ").split(" ")
print(', '.join([names[1].capitalize(), names[0].capitalize()]))