mardi 29 juin 2021

Why aren't all conditions checked in nested 'if statements'?

score = 50

if score >= 60:
  print('elon')
  if score <= 50:
      print('please type number bigger than 0')
else:
  print('please type a number next time')

Can anyone try to help me understand the mechanics of why the second condition is met, but not executed, because it is nested behind a false first condition. I'm struggling with understanding how and when to nest "things". Why isn't the ELSE statement nested?

Aucun commentaire:

Enregistrer un commentaire