python - "list indices must be integers, not list" with enumerate -


i have code

cnames = data["channelnames"] goodchannels = [i i,x in enumerate(cnames) if x!='skipped'] data["channelnames"]=cnames[goodchannels] 

i need channel numbers later, cnames[goodchannels] throws error "list indices must integers, not list"

the list made of integers. there way make work correctly?

cnames[np.array(goodchannels)] not work same error, assuming there else going on here.

you need list comprehension:

data["channelnames"] = [cnames[i] in goodchannels] 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -