Search strings in list containing specific letters in random order

后端 未结 5 1230
刺人心
刺人心 2020-12-05 22:23

I am writing a code in Python 2.7 in which I have defined a list of strings. I then want to search this list\'s elements for a set of letters. These letters must be in rando

5条回答
  •  死守一世寂寞
    2020-12-05 22:54

    Using sets and the in syntax to check.

    wordlist = ['mississippi','miss','lake','que']
    
    letters = set('aqk')
    
    for word in wordlist:
       if word in letters:
           print word
    

提交回复
热议问题