FAQ: Control Flow - Relational Operators II

This community-built FAQ covers the “Relational Operators II” exercise from the lesson “Control Flow”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science
Data Science

FAQs on the exercise Relational Operators II

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

10 posts were split to a new topic: Why doesn’t my code work without a print?

3 posts were split to a new topic: Why doesn’t my function work?

5 posts were split to a new topic: Do I need to be utilizing return or print?

5 posts were split to a new topic: Is there something wrong with my indentation?

when I wrote the function
def graduation_reqs(credits):
if credits > 120:
return “You have enough credits to graduate!”
It showed me error that it wanted graduate_reqs(120) as the function.
But when I checked the solution it showed me the same function as I wrote and did gave any error. There’s definitely some problem in the webpages’ program. Please solve. @discobot


Hi! To find out what I can do, say @discobot display help.

Dude this excercise was unbelievable, i wrote the code perfectly as asked, when i run the code it’s says it’s not correct. After i press the “show solution” button, it shows me the exact same code. Ok fine, number 3 i have to write the print statement even that it showed as wrong while in the solution it was exactly the same code, dude wtf?


I see this issue has already been mentioned before. Still not fixed.

Hey @textjumper17671, welcome to the forums!

Can we see your original code? You never know, maybe something was spelled wrong or you had some extra white space.

Hi stevencopeland, thank you!

Sure thing, absolutely no problem.
So i just redid the excercise this is are the first 2 steps i wrote:

def greater_than(x, y):
if x > y:
return x
if y > x:
return y
if x == y:
return “These numbers are the same”

def graduation_reqs(credits):
if credits >= 120:
return “You have enough credits to graduate!”

The first step seemed to go fine, the second step gives me the error ''did you remember to define graduation_reqs"?

The third went flawless.

Update: I think it’s because of the spaces before the code? That seems to be the only logical issue to me.

Do you think you could format your code so we could see all the whitespace? Try putting three backticks(`) before and after your code?

Check out this post if you need help:

1 Like

it would be nice if someone could tell me what I’m doing wrong here. As far as I understand the task correctly I should only create the function.I want to test it (“run”). If I am asked to test it with an unrealistic return. Is it my mistake or that of the script?

I hope you see the picture if not it is the task 6. Relational Operators II and there the first.

p.s. sorry for the bad English

The code above only returns the equality case, and not the value that is greater than the other. Add that code to your function after the if statement.

1 Like

Oh yes this is what it says. Sorry, I didn’t catch that. That was unnecessary.

1 Like

In Python, why do no we not have to deal with both the true and false scenarios for the functions that we write?

I may be misudnerstanding you but these lessons are just an introduction to the basics of controlloing flow in Python. It’s to teach the syntax and general stucture of conditionals, they’re not meant to be applicable to every possible scenario. More generally you’d wind up with a lot of unnecessary else: pass statements if you had to deal with the False output too.

Working through the Relational Operators II (page 6) instructions:
The first step doesn’t provide values for x and y so I’ve written it as is, and I’ve been consistently getting an error that it is expecting 2 actual values defined for x and y. How am I supposed to know what to use if the instructions don’t say?

These numbers are the same


These numbers are equal

Be sure to use text and variables as specified in the instructions.

:man_facepalming: I knew that! Thanks for the quick response

1 Like