First up :
>>> for l in A: ... if 'why' in l: ... print l ... ['tweet', 'where', 'why', 'how']
For second: (wy any where)
>>> for l in A: ... for i in l: ... if 'wh' in i: ... print l ... break ... ['where', 'what', 'when', 'how'] ['tweet', 'where', 'why', 'how']
for testing at the beginning try this: (using startswith () from @Harido)
>>> for l in A: ... for i in l: ... if i.startswith('wh'): ... print l ... break ... ['where', 'what', 'when', 'how'] ['tweet', 'where', 'why', 'how']
For the third:
To find the index, you can use the A.index(l) method after printing the stamens, for example:
>>> for l in A: ... for i in l: ... if 'wh' in i: ... print l ... print A.index(l) ... break ... ['where', 'what', 'when', 'how'] 1 ['tweet', 'where', 'why', 'how'] 3
But remember that I am not good at Python. Some may give you better ways. (I write C as bad code) I would like to share this link: Guido van Rossum
Edit :
thanks @Jaime, suggesting me for k, l in enumerate(A):
>>> for k, l in enumerate(A): ... for i in l: ... if 'wh' in i: ... print l ... print "index =", k ... break ... ['where', 'what', 'when', 'how'] index = 1 ['tweet', 'where', 'why', 'how'] index = 3