0
What is wrong with this code? It says that TYPE ERROR: Can't multiply sequence by non-int of type 'float'
#function def gwa_result (units, grades): result = [] for i in range(0, len(units)): if grades == "W": grades[i] = 0 units[i] = 0 if grades == "INC": grades[i] = 5.0 units[i] = 3.0 result.append(units[i] * grades[i]) final = (sum(result)) / (sum(units)) return round(final, 3) print(gwa_result(units1, grades1)) print(gwa_result(units2, grades2)) print(gwa_result(units3, grades3)) print(gwa_result(units4, grades4)) print(gwa_result(units5, grades5))
3 Réponses
+ 3
Hi, Bhell Christian Binghay !
I inputed:
units1 = [3, 6, 8]
grades1 = [2, 8, 9]
And run:
print(gwa_result(units1, grades1))
And got:
=> 7.412
What kind of input do you have and what output do you expect?
+ 2
What are values for unitsN, gradesN?
units[i] * grades[i] , looks like grades list having string as well as float values then float*str will raise error..
+ 1
Both the code and the question are incomplete. It will be hard to help you.
Pls save your code in Code Playground as public, then edit your question and replace the "wall of code" by a link to your code in Code Playground.