I'm having some problem extracting the last name from a list.
list = ['Cristiano Ronaldo', 'L. Messi', 'M. Neuer', 'L. Suarez', 'De Gea', 'Z. Ibrahimovic', 'G. Bale', 'J. Boateng', 'R. Lewandowski']
for item in list:
print(item)
print(re.findall(r'(\s(.*))', item))
But the output is as such:
Cristiano Ronaldo
[(' Ronaldo', 'Ronaldo')]
L. Messi
[(' Messi', 'Messi')]
M. Neuer
[(' Neuer', 'Neuer')]
L. Suarez
[(' Suarez', 'Suarez')]
De Gea
[(' Gea', 'Gea')]
Z. Ibrahimovic
[(' Ibrahimovic', 'Ibrahimovic')]
G. Bale
[(' Bale', 'Bale')]
J. Boateng
[(' Boateng', 'Boateng')]
R. Lewandowski
[(' Lewandowski', 'Lewandowski')]
I am curious as to why the last names were returned twice; I only want to get back the last names once.
Can any of you kind folks help? Thank you!
\w+$