vendredi 30 octobre 2020

Combine IF with AND/OR python

Im trying to filter out some "words/characters" out of an python string. Here is my code:


if "MV" not in (str)network_name:
                        if "MOB" not in network_name:
                            if "MG" not in network_name:
                                if "RO" not in network_name:
                                    if "RQ" not in network_name:
                                        if "RM" not in network_name:
                                            if "RT" not in network_name:
                                                if "RC" not in network_name:
                                                    if "RW" not in network_name:
                                                        if "RU" not in network_name:
                                                            if "RA" not in network_name:
                                                                if "RH" not in network_name:
                                                                    print ('OK')

Is there an way to make an oneliner with all of the filters? Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire