[Solved] Storing values in a CSV file into a list in python


Please never use reserved words like list, type, id… as variables because masking built-in functions.

If later in code use list e.g.

list = data['FirstNames'].tolist()
#another solution for converting to list
list1 = list(data['SecondNames'])

get very weird errors and debug is very complicated.

So need:

L = data['FirstNames'].tolist()

Or:

L = list(data['FirstNames'])

Also can check Is it safe to use the python word “type” in my code.

2

solved Storing values in a CSV file into a list in python