My program has the user type a number and depending on that number, it gives a statement. The issue is that no matter what the input is, only the statement "Senior" will print. The others are all ignored.
I've tries many different solutions I've found online, nothing has helped me. Here's the function I'm having trouble with:
credits = float(input("Enter number of credits: "))
if credits >= 7:
print("The classification is Freshman")
elif credits <= 7 >= 16:
print("The classification is Sophomore")
elif credits <= 16 >= 25:
print("The classification is Junior")
elif credits <= 25:
print("The classification is Senior")
else:
print("Error")
CodePudding user response:
Your logic within the if statements are wrong. This is probably what you want:
credits = float(input("Enter number of credits: "))
if credits <= 7:
print("The classification is Freshman")
elif credits > 7 and credits <= 16:
print("The classification is Sophomore")
elif credits > 16 and credits <= 25:
print("The classification is Junior")
elif credits > 25:
print("The classification is Senior")
else:
print("Error")