Ho to check if string contains substring from list - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Ho to check if string contains substring from list (/thread-5370.html) |
Ho to check if string contains substring from list - Rius2 - Sep-30-2017 i want to check if a string contains a substring from a list of string i provide, at the moment i am doing this: if 'U19' in echipa1 or 'U20' in echipa1 or 'U17' in echipa1 or 'U21' in echipa1 : print ("Echipele nu sunt bune")i want to create a list and check from it: NotOklist = ('U19','U20','U17','U21') if echipa1 in any(NotOKlist) print ("Echipele nu sunt bune") RE: Ho to check if string contains substring from list - buran - Sep-30-2017 NotOKlist = ('U19','U20','U17','U21') if any(s in echipa1 for s in NotOKlist): print ("Echipele nu sunt bune") RE: Ho to check if string contains substring from list - Rius2 - Sep-30-2017 Thank you |