python - Get the first url from list that contains 'posts' in it -
i have list:
['http://exampleurl.com/index.php', 'http://exampleurl2.com/in_dex1.php', 'http://exampleurl.com/posts/images', 'http://exampleurl2.com/posts/tags/etc']
how first url contains 'posts'
?
your approach correct needs few changes. can loop through list this:
x = ['http://exampleurl.com/index.php', 'http://exampleurl2.com/in_dex1.php', 'http://exampleurl.com/posts/images', 'http://exampleurl2.com/posts/tags/etc'] in x: if 'posts' in i: print break
Comments
Post a Comment