[python3] Receive Lv.1 report results / Solve problems with approaches and dictionary values

Asked 1 years ago, Updated 1 years ago, 389 views

def solution(id_list, report, k):
    answer = []
    Declareddic = {}
    n = len(id_list) #total number of users
    for x in id_list:
        Report dic[x] = []
    for i in report:
        reporter = i.split("") #["muzi", "frodo"] Reported, reported
        신고dic[reporter[1]] += reporter[0]
    forkin reporting.dic:
        answer.append(len(set(k)))
    return answer

Python tutor identified a problem and reported dic[reporter[1] +=reporter[0] I don't know how to solve the problem of adding "m", "u", "z", and "i" instead of having "muzi" strings in the list at once. I wonder if the problem-solving approach is wrong from the beginning or if I only have to solve the problem in that part.

python python3 dictionary

2023-01-12 01:56

1 Answers

>>> a = []
>>> a += "abcde"
>>> a
['a', 'b', 'c', 'd', 'e']
>>> a = []
>>> a.append("abcde")
>>> a
['abcde']


2023-01-12 05:46

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.