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']
На этой странице сайта вы можете посмотреть видео онлайн Using split function to split words where an empty space is found длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Online Skills 12 Июнь 2017, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 102 раз и оно понравилось 0 зрителям. Приятного просмотра!