Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

searching within python lists

Name: Anonymous 2013-03-19 21:29

if i have
cat = ['smelly', 'furry', 'claws']
dog = ['smelly', 'loud', 'stupid']
animals.append(cat)
animals.append(dog)

how can i easily search the list 'animals' for which list items are labeled 'smelly'. after that i want to somehow mark that 'dog' and 'cat' were found to be similar due to them both having the attribute 'smelly'

simple way to do this /prog/?

Name: Anonymous 2013-03-19 21:38

I don't know exactly what you mean by marking them, but for the first part, you can do [animal for animal in animals if 'smelly' in animal].

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List