jeudi 6 octobre 2016

matching multi-word strings via if statement in python

I got a bit of question here. The input is this line:

configure vlan test bla bla

and its stored in variable line.

If I evaluate it based on my first if statement below it fails

 if ("configure" in line) and (" vlan" in line):
    print("create vlans");

If I evaluate it based on the next if statement below it succeeds.

if ("configure vlan" in line):
    print("create vlans 2");

Why is that? I just simply put the two string together but one works and the other doesn't.

Thanks

Aucun commentaire:

Enregistrer un commentaire