Skip to main content
Remove "Python" tag from title
Link
Jesse Webb
  • 45.5k
  • 32
  • 110
  • 146

Modify items in a list does not give any output - Python

Source Link

Modify items in a list does not give any output - Python

I'm finding really difficult modifying some items in a list. I have a list comparable to a database, and I want to convert string values (which I would consider as missing values) to 99.

database = [2,5,11,33,78498,'abcqwe',13, 18,11,1993,'defrty']

def missing_values(i):
    for i in database:
        if type(i) == str:
            i = 99
    return 'Database cleaned'

When I run it, there are no syntax errors, even though "Database cleaned" does not appear. If I print(database), I see that nothing has actually changed. What I'm doing wrong?