0

else statement prints even if statement is true

MIN_CREDITS = 6 #Be enrolled in a minium of 6 credits MIN_GPA = 2.0 #Must have at least a 2.0 GPA un_Elgibile = 'No' scholar_Elgibility = input('Have you compeleted your financial aid? ') degree_certifcate_program = input('Are you enrolled in a ' + 'degree or certiciate program? ') min_GPA = float(input('What is your GPA? ' )) g_PA = min_GPA credits_enrolled = int(input('How many credits are you enrolled in? ')) enrolled_credits = credits_enrolled if un_Elgibile == scholar_Elgibility: print('You must compelete financial aid form.') if degree_certifcate_program <= un_Elgibile: print('You must register for degree/certificate program.') if g_PA < MIN_GPA: print('Your GPA is less than a 2.0. Sorry you do not qualify for ' + 'financial aid.') if enrolled_credits < MIN_CREDITS: print('You are enrolled in less than 6 ' + 'credits. You do not meet requriements.') else: print('You qualify for a scholarship!') No matter what statement I put the else statement prints. Anybody can help?

7th Oct 2020, 3:53 AM
Gregory R Jean
Gregory R Jean - avatar
2 odpowiedzi
+ 1
Use a boolean variable as status. is_eligible = True if un_Elgibile == scholar_Elgibility: print('You must compelete financial aid form.') is_eligible = False if degree_certifcate_program == un_Elgibile: print('You must register for degree/certificate program.') is_eligible = False if g_PA < MIN_GPA: print('Your GPA is less than 2.0. Sorry you do not qualify for financial aid.') is_eligible = False if enrolled_credits < MIN_CREDITS: print('You are enrolled in less than 6 credits. You do not meet requirements') is_eligible = False if is_eligible: print('You qualify for a scholarship') Comparison for certification should have used == instead of <= Why two variables for enrolled credits? <enrolled_credits> and <credits_enrolled> Next time share a code link instead. Raw text code isn't as easy to analyse. Here's how you share links https://www.sololearn.com/post/75089/?ref=app
7th Oct 2020, 4:07 AM
Ipang
+ 1
I appreciate the help, i'm still a newbie and still learning! Appreciate the help!
8th Oct 2020, 3:21 AM
Gregory R Jean
Gregory R Jean - avatar