dictionary tag

102 questions


1 answers
1 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?


1 answers
1 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 is" else: print "No...

6 days ago

1 answers
1 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.Th...


1 answers
1 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 B Dict A: {'a':1, 'b':2, 'c':3} Dict B: {'b':3,...

6 days ago

1 answers
1 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 functions When repla...

6 days ago

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

Dict is map = { '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
2 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] ...

6 days ago

1 answers
1 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 answers
1 views
0
To find a key with a value in the dictionary...?

You want to find a name by age in a dictionary that stores a key-value pair with a name as key and an age as value.I can compare ages or find values, but I don't know how to access keys. list = {'geor...

6 days ago

1 answers
1 views
0
There are some strange things about Python dictionary generation.

Hello, I'm a beginner at Python.The data in the csv file are in the first line, Rank, Major_code, and so on There are data from the next line. I'm making a dictionary by combining the first line data ...

6 days ago
- 1 - »

© 2022 pinfo. All rights reserved.