Trouble with while loop in python function -



Trouble with while loop in python function -

i have little app asks movie. when rating on 50, homecoming watch it. if doesn't, take movie. though when status in moviedec, won't go top of function calculate score of movie. can't figure 1 out.

def getscore(): take = raw_input("pick film ") 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 homecoming rating1, rating2, stars def moviedec(): critic, aud, stars = getscore() print 'critics gave %s' %critic print 'audiences gave %s' %aud print 'the average rating %s' %stars while stars < 50: print "that's no good, pick again" getscore() print 'good choice.'

you not updating stars variable in loop. try:

while stars < 50: print "that's no good, pick again" critic, aud, stars = getscore()

python

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -