Learn

An equality condition allows us to check whether two values are the same.

For example, imagine a store holding a sale every Wednesday. The cashier would need to compare whether the day “is equal to” Wednesday. In code, the phrase “is equal to” is often represented as “==”. This code might look like.

Add up items If Today == Wednesday { Apply Discount to purchase } Display total

Sometimes we want to define a condition in terms of check whether two values are not equal. For checking if values are different, we use != in code. Imagine we are trying to find an empty room for a meeting:

Go to conference room If (room != empty) { Find a different room } Start meeting

Here, we would start a meeting if the room we found was empty, or we would have gone to a different room if someone was already there.

We use equality conditions when we need to see whether two values are the same. With Codey, we will check whether the block ahead is a hedge. Let’s get started!

Instructions

Codey is trying to get to the flag, but there are some hedges in the way. When Codey sees a hedge, they need to move out of the way of it. Can you make a program that avoids the hedges?

Hint

Codey should move up when the block to the right is a hedge.

Solution
While program is running If Space right is hedge Move up Move right

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?