Linked Questions

2 votes
3 answers
7k views

I have the following data: [{'id': ['132605', '132750', '132772', '132773', '133065', '133150', '133185', '133188', '133271', '133298']}, {'number': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '...
user avatar
3 votes
1 answer
12k views

When I do: d = {'x': 1, 'y': 2, 'z': 'randy'} print(d.keys()) The result is: dict_keys(['x', 'y', 'z']) Why is there the dict_keys? Is there a way to get rid of it?
Roger Tan's user avatar
0 votes
2 answers
4k views

given a dictionary: entries = {'blue': ' the color of the sky', 'coffee': ' fuel for programmers'} how do I append the keys into a list? I got this far: results = [] for entry in entries: ...
jay's user avatar
  • 11
1 vote
1 answer
2k views

Trying to do a simple todo app with flask and sqlalchemy and since I have never worked with checkboxes in flask before, i have the following problem. App is class Todo(db.Model): id = db.Column(...
April's user avatar
  • 31
-2 votes
4 answers
5k views

So I have a dictionary which is like - {'gaining': 34, 'Tinga': 42, 'small': 39, 'legs,': 13,}. Is there a way in which i can print it out so that it becomes a list like - [ gaining, Tinga, ...
The World In 5's user avatar
-2 votes
1 answer
448 views

list=['Mary','Bob','Linda'] dictionary={0:'Mary', 1: 'Anna', 2:'Bob', 3:'Alice', 4: 'Linda'} if list in set(dictionary.values()): name = dictionary.get(None, ...
BobbyZhao's user avatar
-2 votes
2 answers
150 views

source = [{'address': 15620, 'street': 490}, {'address': 10180, 'street': 2187}, {'address': 10190, 'street': 670}, {'address': 20900, 'street': 572}, {'address': 8190, 'street': 1103}, {'address': ...
dmz0004's user avatar
  • 11
-2 votes
1 answer
329 views

x={1: [6, 3], 4: [6, 9]} For example the result could return only the first key or the second key.
Image Privacy's user avatar
0 votes
1 answer
171 views

I am trying to extract first element from a dictionary built as follows: vocab=vectorizer.vocabulary_ {k: v for k, v in sorted(vocab.items(), key=lambda item: item[1],reverse=True)} Output: {'zum': ...
user avatar
-2 votes
1 answer
109 views

I work with a function that when you call her it return dictionary, which command shoud I write that will print the keys of the dictionary? Thanks.
Rea Gavriel Klayman's user avatar
0 votes
0 answers
83 views

Here is the code: max({1: "one", 2: "two", 3: "three"}) It returns 3. I wonder what is the rule here? Function max() operates on a dictionary, how does the comparison work on a dictionary? So the ...
my_question's user avatar
  • 3,315
0 votes
0 answers
69 views

I am importing a excel file which have several sheets. I am using the next line of code to do that: books = pd.read_excel('books2.xlsx', sheet_name=None, index_col=None, na_values=['NA']) 'books' now ...
Ivanovitch's user avatar
0 votes
0 answers
56 views

I need to create lists out of dictionary keys. Something like this: dictionary = {"City": "New York", "Population": "idk", "Location": "America&...
areedy's user avatar
  • 115
589 votes
15 answers
429k views

What are "iterable", "iterator", and "iteration" in Python? How are they defined? See also: How to build a basic iterator?
thechrishaddad's user avatar
27 votes
4 answers
42k views

In Python 2.7, dictionaries have both an iterkeys method and a viewkeys method (and similar pairs for values and items), giving two different ways to lazily iterate over the keys of the dictionary. ...
Michael J. Barber's user avatar

15 30 50 per page