mercredi 2 juin 2021

Stopping checking a conditional while looping over an iterable

so I have the following question. Let's say that we're doing a standard "password strength check", meaning that if a password (a string) has an uppercase letter, lowercase letter, and a number in it, it's considered to be "strong" super simple example of what I have in mind:

for character in 'asdASD123':
  if character.isupper():
    something
  if character.islower():
    something
  if character.isnumeric():
    something

and if all of these conditions at any point are met, then the password is strong. And my question: Is it somehow possible to stop checking a certain condition if it already has been met? In this example, the "islower" condition will be satisfied on the very first character. Is there a way to eliminate it from being checked in further loops? If so, how to do that? Is there a way to store the conditions in a list, and then remove them from that list once they are met, or something to that effect?

Aucun commentaire:

Enregistrer un commentaire