Using split function to split words where an empty space is found

Publicado el: 12 junio 2017
en el canal de: Online Skills
102
0

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']


En esta página del sitio puede ver el video en línea Using split function to split words where an empty space is found de Duración hora minuto segunda en buena calidad , que subió el usuario Online Skills 12 junio 2017, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 102 veces y le gustó 0 a los espectadores. Disfruta viendo!