0
What is wrong with my code plzz tell me i am in hurry
https://sololearn.com/compiler-playground/ck5wrPF8lZug/?ref=app
3 Answers
+ 5
# Hi, MohdSalmanAnsari !
# You can check this solution. Maybe it gives you a hint:
def push_highest_score(stack, students_scores):
THRESHOLD = 80
for scores in students_scores.values():
highest_score = max(scores)
if highest_score >= THRESHOLD:
stack.append(highest_score)
stack = []
students_scores = {
"ram": (75, 89, 95),
"shyam": (91, 54, 75),
"vivek": (54, 46, 80),
"ayush": (46, 63, 19)
}
push_highest_score(stack, students_scores)
print(stack)
+ 3
#you did not pass stu_stk to your function.
#your dict is delimited with; use ,
#if you are passing the dictionary directly, you don't have to assign it to a variable. Your assignment is wrong, too.
#you have to print stu_stk to see the result.
stu_stk = []
def push_element(stu_stk, stu_dict):
for k in stu_dict:
if max(stu_dict[k]) >= 80:
stu_stk.append(max(stu_dict[k]))
push_element(stu_stk,{"ram":(75,89,95), "shyam":(91,54,75), "vivek":(54,46,80), "ayush":(46,63,19)})
print(stu_stk)
+ 2
The function does not return or print anything, and is passed stu_stk as an argument. So, it modifies stu_stk in its local scope, and then that disappears.
Beyond that, Iâm not sure what this code is meant to do.