I'm somewhat new to python (switching from IDL), so I apologize if I'm not using the right terminology. I've tried looking for similar [questions](https://stackoverflow.com/questions/1012185/in-python-how-do-i-index-a-list-with-another-list), but can't seem to figure it out. I have two lists and I'm trying to create a histogram of the data where dat2 = 1. I've tried doing this multiple ways and it keeps giving me a TypeError

```
import matplotlib.pyplot as plt
import numpy as np
data = [1.1,4.2,5.3,8.6,10.0,1.2,41.4,23.2]
dat2 = [1,1,1,1,2,2,2,2]
ind = [i for i,v in enumerate(dat2) if v==1]
bins = np.arange(0,45,5)
plt.hist(data[ind],bins)

```

The error points to the hist() line and says "TypeError: list indices must be integers, not list." I've tried `ind=map(int,ind)` and `ind=[int(i) for i in ind]` with no luck.