Question: I have a CSV file with date, time, Positive and Negative columns. There are duplication of dates such as row 4 and 5 with different positive and negative value. I wanted to match the user input date with the dates in the csv file and return the index of the date in order for me to get the different positive and negative values. 

However, I tried to for loops but it always return me the first index of the date. 

```
The CSV file look like this:
Date      Pos Neg
20180402   1   0
20180402   0   1
20180401   0   1
20180402   1   0

for i in range(len(combine_list)): 
xdate = combine_list[i][0]
print(xdate)
if user_date3 ==xdate:
    print("yes")
    count_price +=1
    index1 = date_list.index(xdate)
    print(index1)
    #index1.append(index1)

```

Sorry if the code if messy as I just started to learn how to code. Any help is appreciated. Thanks! :)

Answer: 
A [for loop will iterate over items in a sequence](https://docs.python.org/3/tutorial/controlflow.html#for-statements). If you need a reference to the index of each item in the sequence, use [`enumerate()`](https://docs.python.org/3/library/functions.html#enumerate). 

Assuming `combine_list` is a list of lists:

```
combine_list = [['20180402',1,0],
                ['20180402',0,1],
                ['20180401',0,1],
                ['20180402',1,0]]

for i, line in enumerate(combine_list): 
    xdate = line[0]
    print(xdate)
    if user_date3 == xdate:
        print("yes")
        count_price +=1
        index1 = i
        print(index1)
        #index1.append(index1)

```
I'm assuming that you have imported your .csv file as a table multi-dimensional array.

```
table = [['Date', 'Pos', 'Neg'],
         [20180402, 1, 0],
         [20180402, 0, 1],
         [20180401, 0, 1],
         [20180402, 1, 0]]

def filter_data(table, date):
    filtered_data = [table[0]]
    for row in table[1:]:
        if row[0] == date:
            filtered_data.append(row)
    return filtered_data

print filter_data(table, 20180402)

```