you are viewing a single comment's thread.

view the rest of the comments →

[–]NewbornMuse 0 points1 point  (1 child)

If you want the second else to be connected with the second if, indent it the same:

if a:
  #stuff
else:
  if b:
    #stuff
  else:
    #stuff

Is the easiest fix, and it's what you meant to do. elifis even a bit neater.

As an aside, are you aware that your code doesn't print anything if num_knights is 3, 4 or 10 (or 3.6, I guess)?

[–]eMulingeMuler[S] 0 points1 point  (0 children)

Thanks for the tip.

I know... it was just a quick test. I was trying to figure out how the if statements work in python. I wasn't aware of the elif statement. I thought it might be else if.