So I have a list of strings that I would like to convert to a dictionary. I want the keys in the dictionary to be the names of the strings and the... other part... i forget what its called, the part after the keys, to be how many times the string occures, this is part of a larger program so I won't submit all the code I have so far, but the list I want to convert is the following (There are a couple other lists aswell but I figure I can probably just change the code to fit them):
s2ID = ['a01', 'a02', 'a02', 'a02', 'a03', 'a03', 'a03', 'a03']
I won't know how many elements will be in the list in the final version and these are just values i've subbed in so that I have something to work with, so keep in mind that I won't necissarily have one a01 and 2 a02's in the final version, i could also have a75 for all i know, all i know is that they will follow the format of a(int)(int), not sure if this affects the code or not but just in case
Any help would be greatly appreciated as would an explanation (even if its a quick and simple one) of any code given. Thanks in advance for the help!
s2ID = ['a01', 'a02', 'a02', 'a02', 'a03', 'a03', 'a03', 'a03']
I won't know how many elements will be in the list in the final version and these are just values i've subbed in so that I have something to work with, so keep in mind that I won't necissarily have one a01 and 2 a02's in the final version, i could also have a75 for all i know, all i know is that they will follow the format of a(int)(int), not sure if this affects the code or not but just in case
Any help would be greatly appreciated as would an explanation (even if its a quick and simple one) of any code given. Thanks in advance for the help!
Comment