Home > other >  Dictionary to add a list of questions
Dictionary to add a list of questions

Time:12-10

List of specific questions as follows, for p, dictionary for the new dictionary, k now for setting key for T, ultimately to achieve k={' T ':' s, 'T', 'w', 'T' : 'q',... , 'T' : 'a'} such effect, as the how to operate it, the Internet for a long time, but the final result of all sorts of ways style is k={' T ': [' s',' w ', 'q',......, 'a']}, please advise, thank you

P=[' s', 'w', 'q',......, 'a']
K={}

CodePudding user response:

Theoretical and logic doesn't work, 'T' is equivalent to the number of pages of the dictionary, k={' T ': [' s',' w ', 'q',......, 'a']} said the 'T' in the page s, w, q, a
K={' T ':' s, 'T', 'w', 'T' : 'q',... Said, 'T' : 'a'} what do you mean??????? K all pages of the dictionary is called the 'T' page? It from the dictionary if you want to get the 'T' page value, he is to return, s or w??

CodePudding user response:

Really want to give T, then define multiple dictionaries, k1={' T ':' s'}, k2={' T ', 'w'}...

CodePudding user response:

The dictionary keys are not repeatable, so there can be only one dictionary K which the 'T' key, if there is repeated, the value behind the will overwrite the previous,
Can put them in a kind of data matching
P=[' s', 'w', 'q', 'a']
> K=[(' T ', I) for I p] in
> K
[(' T ', 's'), (' T ', 'w'), (' T ', 'q'), (' T ', 'a')]

CodePudding user response:

To correct the above:
P=[' s', 'w', 'q', 'a']
> I} [{k='T' : for I p] in
> K
[{' T ':' s'}, {' T ', 'w'}, {' T ':' q '}, {' T ':' a '}]
  • Related