[Tutor] help with elif statements

andrade1@umbc.edu andrade1 at umbc.edu
Thu Oct 13 03:04:46 CEST 2005


hello

below is my code and everytime I input a value of 16 or more it keeps
returning sophomore. could anyone help me figure out what to change so
that it won't return sophmore for things greater than or equal to 16?

def getcredits(num):
    if num < 7:
        return 'Freshman'
    elif num >= 7:
        return 'Sophomore'
    elif num <16:
        return 'Sophomore'
    elif num >= 16:
        return 'Junior'
    elif num < 26:
        return 'Junior'
    else:
        return 'Senior'

def main():
    g = input('Enter number of credits:')
    print 'Your standing is %s' % (getcredits(int(g)))

main()



More information about the Tutor mailing list