Python Question. Please what is the proper indentation for this? I am getting er
ID: 3718959 • Letter: P
Question
Python Question. Please what is the proper indentation for this? I am getting error messages on indentation. Thanks!
GNU nano 2.5.3 File: Mo /usr/bin/python3 #prompting user for required info name-input 'please enter your name: ') major-input 'please enter your intended major:n') courses-int (input 'AP courses completed so far?n')) stemCourses int (input ('Of those courses completed, how many are STEM courses? ')) stemGpa print ('GPA for each science related course on new 1ine ') for i in range (stemCourses) stemGpa.append (float (input ())) overal IGpa-float (input ( ·Overall GPA? ' ) ) eligibleCourses-["Science", "Technology Engineering", "Math"]#making list and overallGpa>=3.0) :#checking for all eligibility conditions of eligible courses if((major and in eligibleCourses) print( 'qualified') average-sum (stemCourses) (courses>-5) / len(stemCourses) #getting avg gpa of science courses #checking the amount eligible if (len (stemCourses)4and average-3.8) elif(len(stemCourses)-3 and average >=3.5) : elif (len(stemCourses)-2 and average >=3.25) : amount- 5000 amount=40 00 amount-3000 else: print ( 'qualified but not elgible') file open("scholarshipF11e.txt " ,"w") file.write "student with name : "+name+" is eligible for scholarship " writing to file else: print('not eligible')Explanation / Answer
Even though I'm not sure about the program's logic, The mistake I found is , in your if else structure you wrote two else conditions at the end, which is incorrect.
if else structure should always be like
if:
elif:
elif:
.
.
.
.
else:
There should always be only single else: condition in if else ladder
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.