Python convert pairs list to dictionary -


i have list of 50 strings integer representing how occur in text document. have formatted shown below, , trying create dictionary of information, first word being value , key number beside it.

string = [('limited', 1), ('all', 16), ('concept', 1), ('secondly', 1)] 

the code have far:

my_dict = {} pairs in string:     int in pairs:        my_dict[pairs] = int 

like this, python's dict() function designed converting list of tuples, have:

>>> string = [('limited', 1), ('all', 16), ('concept', 1), ('secondly', 1)] >>> my_dict = dict(string) >>> my_dict {'all': 16, 'secondly': 1, 'concept': 1, 'limited': 1} 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -