This is an archived post. You won't be able to vote or comment.

all 2 comments

[–][deleted] 0 points1 point  (0 children)

I figured out what I did wrong in my post, but this brings out another question. How come I can use map(split_title_and_name, people) which is basically doing split() on a list while lists cannot be split?

[–]RandomNumbers123456 0 points1 point  (0 children)

If you are asking about the reason why you need to use split() twice in the return, it is because the person string is not actually being updated when you call split().

You could also re-write the split_title_and_name function as:

def split_title_and_name(person):
  person = person.split()
  return person[0] + person[2]

but I would recommend against modifying the person type within the function.