mercredi 13 juin 2018

python: categorize and group strings by my own rules

I am looking for ways to categorize a list of strings into groups that I specify. If I have the following,

keywords = ['cat', 'dog']
number = '0123456789'

and input 'cat 30495 hello' I'd like this to belong to a group something like: [keywords][number][strings that are not keywords]. What would be an effective way of solving such problem? thanks.

Aucun commentaire:

Enregistrer un commentaire