Screen Link:
My Code:
from csv import reader
def find_col_index(csv_filename, col_name):
opened_file = open(csv_filename)
read_file = reader(opened_file)
csv_filename = list(read_file)
col_index = -1
for i in csv_filename[0]:
for j in range(len(csv_filename[0])):
if i == col_name:
col_index = j
return col_index
print(find_col_index('users.csv', 'name'))
print(find_col_index('users.csv', 'id'))
print(find_col_index('users.csv', 'age'))
My output when code is ran:
3
3
-1
My output when Submit answer is clicked:
"Your function returned an incorrect answer. Input: ['test.csv', 'h1'] Your answer: 5 Expected answer: 0"
How come the structure of my code is incorrect? Am i missing an indent? Please clarify