193k views
4 votes
Ask the user for their full name (using a single input), write a section of code below that will correctly print the users first name and last name on separate lines.

User Jeff Ayan
by
4.8k points

1 Answer

3 votes

name = input("Enter your name: ")

lst = name.split()

print(lst[0])

print(lst[1])

We split the name apart at the spaces and print out the object at index 0, which is the first name and at index 1, which is the last name.

I hope this helps!

User Amartine
by
4.7k points