I have started by creating a list called namelist consisting of three names. First and last names are separated by space
namelist=["Emma Wild", "Liam Wilson", "Elijah Mason"]
To find the first names, I will find the space choose the first part [0] of the split and put the names into new list called firstnames.
firstnames = [name.split(' ')[0] for name in namelist]
firstnames
OUTPUT:
['Emma', 'Liam', 'Elijah']
To create lastnames list, use the same format, only selecting the part after the space [1]
lastnames = [name.split(' ') [1] for name in namelist]
lastnames
OUTPUT:
['Wild', 'Wilson', 'Mason']
On this page of the site you can watch the video online Using split function to split words where an empty space is found with a duration of hours minute second in good quality, which was uploaded by the user Online Skills 12 June 2017, share the link with friends and acquaintances, this video has already been watched 102 times on youtube and it was liked by 0 viewers. Enjoy your viewing!