vendredi 4 octobre 2019

organizing if statements in for loops to pull specific data from a string

I have the following

items=' g energy 4"3/4 drilling jar'
print(items.split())
if 'energy' or 'ge' in items.split():
    print('E')
if 'slb' or 'schlumberger' in items.split():
    print('S')
if 'oes' or 'overseas' in items.split():
    print('O')

output 
E
S
O

what I want is to check if any of the words are in the string but what i am getting is that it tells me all the words are in the string i want to check the word not the characters of the word how can I go around to achieve that?

Aucun commentaire:

Enregistrer un commentaire