Computer choice part 2: What am I missing here? Formatting quirk?


#1

INCORRECT

I was playing around with this exercise for ages unsure why my code wasn't being accepted, until I moved the formatting around. No characters were added or taken away, so the code is essentially "the same" in both, but one is accepted and one not.

Is this just a quirk of codecademy or have I missed something regarding formatting code?

Many thanks for your advice!


#2

CORRECT

This is the version that was accepted as correct


#3

What was changed? And to be honest they are both incorrect:

First of all else is the default case so it doesn't need a condition and using one will cause trouble. See this link:

And the other problem is that these do not work:

0.33 <computerChoice <0.66

The problem is that the computer can't handle context so it executes it one by one:

 (0.33 <computerChoice) <0.66
 (true/false) <0.66
 false/true

The last line comes because true has a numerical value of 1 and 0 of false. So if you go through it you can see that this is really evil because it does almost the opposite of what it is supposed to do but the syntax is not wrong so you don't get an error. It's like writing a sentence in correct grammar that doesn't make any sense. So be careful here and maybe have a look at the FAQ thread in the Archived post.