FAQ: Code Challenge: Control Flow - Movie Review

#1

This community-built FAQ covers the “Movie Review” exercise from the lesson “Code Challenge: Control Flow”.

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

Computer Science
Data Science

FAQs on the exercise Movie Review

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

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!

#2

Hi guys, I’m just getting familiar with the basics of Python. However I don’t understand, why I get here the print out on terminal “None” 3x times. See picture. Thanks for help.

#3

I am also new, I think, the issue could be that you used print for every if and else. I think, when you use return then it will store the value, without return it will be “None”

#4

Here is mine:
def movie_review(rating):
if rating <= 5:
return “Avoid at all costs!”
elif rating > 5 and rating < 9:
return “This one was fun.”
else:
return “Outstanding!”

1 Like
#5

@microrunner74470 Hi, did you understand his answer? I’d like to explain it to you further if not.

#7

so awesome thing when testing ranges that i found,

if 5 <= rating < 9:
    return "This one was fun."

Was over here at stackoverflow

#8

Handy when all we want to check is one interval. If there are multiple intervals then it would overkill when simple comparisons will do the job.

You hit on ‘range’, and that’s where an inequality expression is handy.

def double_at_index_if(array, index):
    n = len(array)
    if -n <= index < n:
        array.insert(index, array.pop(index) * 2)
    return array

Above may look similar to an exercise we did a while back, only switched it for a bit of fun. The array will be manipulated at any valid index.

It gets real fun when we introduce exception handling.

def double_at_index_try(array, index):
    try:
        array.insert(index, array.pop(index) * 2)
        return array
    except (IndexError, ValueError, TypeError):
        return array
print (double_at_index_if([2, 5, 7, 9], 2))
print (double_at_index_try([2, 5, 7, 9], 2))
print (double_at_index_if([2, 5, 7, 9], -5))
print (double_at_index_try([2, 5, 7, 9], 4))
[2, 5, 14, 9]
[2, 5, 14, 9]
[2, 5, 7, 9]
[2, 5, 7, 9]