U might wanna change the code to something along the lines of
def getcredits(num):
if num < 7:
return 'Freshman'
elif num >= 7 and num <16
return 'Sophomore'
elif num >= 16 and num < 26:
return 'Junior'
Etc...
Or even
def getcredits(num):
if num < 7:
return 'Freshman'
elif num <16
return 'Sophomore'
elif num < 26:
return 'Junior'
...
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of [EMAIL PROTECTED]
Sent: Thursday, 13 October 2005 2:05 p.m.
To: [email protected]
Subject: [Tutor] help with elif statements
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()
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor