samedi 2 mai 2020

Stand alone 'Else' in a for loop - Python [duplicate]

Can someone please explain the stand alone else part in the following code. I vaguely understand that it would be executed on completion, but I still can't quite wrap my head around it.

for count in outerLoop:
  for a, b in listOfTuples:
    if a != b:
      print "Not Equal"
      break
  else:
    print "Doesn't matter"

Aucun commentaire:

Enregistrer un commentaire