I'm new to coding an I'm having problems with conditional/flow statements


#1



Replace this line with your code.


#2

So your problem is in the conditional statements? Alright. Let's have a look at the very first Conditional statement that you see in Codecademy.

answer = "Left"
if answer == "Left":
    print "This is the Verbal Abuse Room, you heap of parrot droppings!"

In this case we set the variable answer equal to a string, "Left". Just like you have learned before, right? So that is just a variable. Now we have the first if- statement:

if answer == "Left":
    print "This is the Verbal Abuse Room, you heap of parrot droppings!"

Before this exersice you learned about Comparatos & Booleans: They are very useful with conditional statements.

Thing to remember #1. In if statements, the code always checks if the Conditional statement is True, and gives an output. Otherwise there are no outputs, and the code continues working. You can check whatever you want, print and return whatever you want, but remember to make sure that everything is defined.

Python is very similar to english, so think about this sentence for a little bit more, there is something familiar, right?

"If answer is equal to left."
"Print out the output."

Your current code just checks if answer is equal to "Left". The statement is True, right? answer equals left. The output is "This is the Verbal Abuse Room, you heap of parrot droppings" and the kingdom is all right.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.