Q:

Remove character from a list made of a data in a file

Well I have a file with this data on it:

Jesus Rodriguez, 5 E 5.2 1.7
Luka Zorichk, 21 P 11.2 4.8
Jorge Campillons, 15 L 7 3.3

And more data.. Each line has a name, the numbers, the position they play, number of points and the ratio of rebounds ("Jesus Rodriguez", "5", "E", "5.2", "1.7").
Okey the problem that I have is when I get the data from the file, and the name is added to the list with a comma and I do not want that character on it. Here's the code that I have for now:
def leeFich(f):
    listaDatos = list()
    d = open(f)
    for lin in d:
        listaDatos.append(lin.strip())
        for i in listaDatos:
            i.replace(',', ' ') // Here is what I have tried to remove the comma
    return(listaDatos)

print(leeFich("ligaBaloncesto.txt"))

And the output still has the comma in the first item in the list that I just made.

Output:['Jesus Rodriguez, 5 E 5.2 1.7', 'Luka Zorichk, 21 P 11.2 4.8', 'Jorge Campillons, 15 L 7 3.3', '']
Expected Output:['Jesus Rodriguez 5 E 5.2 1.7', 'Luka Zorichk, 21 P 11.2 4.8', 'Jorge Campillons, 15 L 7 3.3', '']

A:

Firstly, str.replace doesn't work in-place. Besides, you can perform the replacing on few lines above while you strip the line. Secondly, for reading a file object it's better to use with statement that closes the file at the end of the block and doesn't open the chance of memory leak for you. Thirdly, instead of creating a list and calling the append attribute on it at each loop you can simple create your list using a list comprehension.
def leeFich(f):
    with open(f) as d:
        lista_datos = [lin.strip().replace(',', '') for lin in d]
    return list_dataos

