Should any list item begin with a string?

I am trying to verify that any list item starts on a specific line. How can I do this with a for loop? IE:

anyStartsWith = False for item in myList: if item.startsWith('qwerty'): anyStartsWith = True 
+8
python list startswith
source share
1 answer

Use any() :

 any(item.startswith('qwerty') for item in myList) 
+30
source share

All Articles