How remove parts of a value in each value of a list?

Question:

I have this list:

original_list = ['1 b Victor','1 b Pedro','1 b Laura','1 b Maria']

I want to remove "1 b" from each value of the list and reach this example list:

final_result = ['Victor', 'Pedro', 'Laura', 'Maria']

How can I do this?

Asked By: Ítalo Lima

||

Answers:

Call str.replace() in a list comprehension.

final_result = [s.replace('1 b ', '') for s in original_list]
Answered By: Barmar
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.