Posts

Showing posts with the label substring

How to match substring in a string using Python [duplicate]

Image
Clash Royale CLAN TAG #URR8PPP How to match substring in a string using Python [duplicate] This question already has an answer here: I have a list of substrings that I have to match in a string iteratively; if matching then perform the desired functionality. The problem is that, whenever I tried to access the list with loops it does not work. Otherwise if I hard code it then it works. I do not understand why it is so? My code is here: players_list = ['Circket', 'PSL', 'IPL', 't20', 'shahid afridi', 'aamer yamin'] length = len(players_list) cur.execute("SELECT tweet FROM tweets_data") # Query for getting specific attribute length = len(players_list) for row in cur.fetchall(): i = 0 while (i<length): #print players_list[i], 'tweet value', row if players_list[i] in row: print 'list item:', players_list[i] print row else: print 'Else statemen...