What do you think would be the best way to write this structure

if testA:
  actionA()
  if testB:
    actionB()
    if textC:
      actionC()
    else:
      actionDefault()
  else:
    actionDefault()
else:
  actionDefault()

if I want to write only one call to actionDefault() ?

if testA:
actionA()
if testB:
actionB()
if textC:
actionC()
else:
actionDefault()

this will bypass all the others as if any of the test things arent right it will skip it and go to action default

This will only execute actionDefault once.

do_action = 0
if testA:
  actionA()
  if testB:
    actionB()
    if textC:
      actionC()
    else:
      do_action=1
  else:
    do_action=1
else:
  do_action=1
if do_action:
  actionDefault()

This would do the trick, but would not be very readable:

if testA:
    actionA()
    if testB:
        actionB()
        if testC:
            actionC()

if not(testA and testB and testC):
   actionDefault()

if testA:
actionA()
if testB:
actionB()
if textC:
actionC()
else:
actionDefault()

this will bypass all the others as if any of the test things arent right it will skip it and go to action default

This will not work for:
testA = True
testB = False
testC = False

This question has already been answered. Start a new discussion instead.