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

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -