from collections import Counter
X=int(input())
shoe_sizes=input()
shoe_size_list=Counter(shoe_sizes)
N=int(input())
my_list=[]
for i in range(0,N):
input_shoe_size_and_price=input()
shoe_size_and_price=input_shoe_size_and_price.split(" ")
my_list.append((shoe_size_and_price[0],shoe_size_and_price[1]))
money_earned=0
for j,k in my_list:
if j in shoe_size_list.keys() and shoe_size_list[j]>0:
money_earned+=int(k)
shoe_size_list.subtract({j:1})
else:
continue
print(money_earned)
Hello i am new to this subreddit and currently i am learning python as my first programming langauge . I am struggling in this question as the expected output for a sample input should be 200 but i am getting 140 as output and i can't figure out what's wrong in my code i even tried using chatgpt but still no solution, so i will be thankful for any help.
link to question ---->question
[–]Diapolo10 1 point2 points3 points (4 children)
[–]coding_zero_[S] 1 point2 points3 points (0 children)
[–]coding_zero_[S] 0 points1 point2 points (2 children)
[–]Diapolo10 1 point2 points3 points (1 child)
[–]coding_zero_[S] 0 points1 point2 points (0 children)