dictionary tag

93 questions


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

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] Repor...

1 years ago

1 answers
479 views
0
KeyError : 3 during dictionary call

I'm currently studying formatting.x = [10, 11, 12]x1=[13,14,15]First element in the list = {0[0]}.format(x)y = {a: 10, b: 11, c: 12}A key value in dictionary = {0[a]}.format(y)A key value in dictionar...

2 years ago

1 answers
155 views
0
Is there a way to access each object more efficiently when writing a data structure map?

I'd like to check all the mapped pairs by rotating the repeat statement. What's the most efficient way?And does the order of the objects change depending on the map implementation?

2 years ago

1 answers
103 views
0
I'd like to make sure that the Python Dictionary has a specific key

I'd like to investigate if there is a specific key like the title.I made my own code.I'd appreciate it if you could teach me a better way.if 'key1' in dict.keys(): print There iselse: print None

2 years ago

1 answers
198 views
0
How do I erase the elements of Dict instead of pop?

You are about to erase the element of dict from Python.I know how to erase it with dict.pop()pop() returns elements that are deleted, right?I'd like to get the disc with the elements removed back.The ...

2 years ago

1 answers
120 views
0
To combine two dicts with overlapping keys

If there are overlapping keys when combining two dict, I would like to add a value corresponding to the key.For example, if you have the following A and BDict A: {'a':1, 'b':2, 'c':3}Dict B: {'b':3, '...

2 years ago

1 answers
174 views
0
Can I change the string to dict?

s = {'muffin' : 'lolz', 'foo' : 'kitty'} -> {'muffin' : 'lolz', 'foo' : 'kitty'}I want to change the string to dict like this.My co-developer made me return the string on all functionsWhen replacin...

2 years ago

1 answers
131 views
0
To reverse the key-value of a dict

Dict ismap = { 'a': 1, 'b':2 }Flip the key-value when present. inv_map = { 1: 'a', 2: 'b' }I want to make it like this.How do I flip a key-value pair?


1 answers
116 views
0
I want to increase the value after checking whether there is a key in the dict, so please give me some advice

Dict already exists, and when I have a key, check whether dict[key] is None or not, and I thought it would work like the code below, but it didn't work, so I'm asking you a question. if (my_dict[key] ...

2 years ago

1 answers
104 views
0
Please help me) I'm inquiring about how to call JSON on OrderedDict

Since json.dump can write OrderDict, I know that OrderDict can be used as JSON's input. What should I do if I want to write output?

- 1 - »

© 2024 OneMinuteCode. All rights reserved.