Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
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 Parker210,850 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.