0

I have a small app that asks for a movie. When the rating is over 50, return watch it. If it doesn't, choose another movie. Though when I get to the condition in movieDec, it won't go back to the top of the function to calculate the score of the movie. Can't figure this one out.

def getScore():
   choose = raw_input("pick a movie ")
   rt = RT()
   info = rt.search(choose)
   rating1 = info[0].get('ratings').get('critics_score')
   rating2 = info[0].get('ratings').get('audience_score')
   stars = (rating1 + rating2) / 2
   return rating1, rating2, stars


def movieDec():
   critic, aud, stars = getScore()
   print 'Critics gave it a %s' %critic
   print 'Audiences gave it a %s' %aud
   print 'The average rating is %s' %stars
   while stars < 50:
       print "That's no good, pick again"
       getScore()
    print 'Good choice.'

3 Answers 3

2

You are not updating the stars variable in the loop. Try:

while stars < 50:
   print "That's no good, pick again"
   critic, aud, stars = getScore()
Sign up to request clarification or add additional context in comments.

Comments

0

In your loop, you are ignoring the return value of getScore():

   getScore()

Change that to:

   critic, aud, stars = getScore()

Comments

0

this corrected code above would call getScore() function 2nd time (if stars <50) but then it won't display the scores until the loop looks like:

while stars < 50:
   print "That's no good, pick again"
   critic, aud, stars = getScore()
   print 'Critics gave it a %s' %critic
   print 'Audiences gave it a %s' %aud
   print 'The average rating is %s' %stars

1 Comment

Instead of printing the whole thing again, you could just call movieDec() again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.