Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
How does one accommodate for last names with a space in them?
How does one accommodate for last names with a space in them in a scenario like this? For example, the last name "De Longhi"? Thanks!
Steven Parker228,039 Points
The "split" method takes an optional keyword argument to limit how many splits are performed:
first, last = input("Enter your full name: \n").split(' ', maxsplit=1)
And if the name was something like "Anne Marie Lewis?"
My sister-in-law would not like that. This is why separate boxes for first and last names works best. But "split" is a neat trick - just not for this
There are many times when the user would prefer to take responsibility for designating their family and given names. Take some of my friends: Chang Woo Hee, Horvat Andras, Anna Lopez Gonzales, - or even myself when I use all four names in my official legal name.