This is based on this question: python convert list to dictionary
The asker provides the following:
l = ["a", "b", "c", "d", "e"]
I want to convert this list to a dictionary like:
d = {"a": "b", "c": "d", "e": ""}
While the grouper recipe is quite interesting and I have been "playing" around with it, however, what I would like to do is, unlike the output dictionary wanted by that asker, I would like to convert a list with strings like the one above into a dictionary where all values and keys are the same. Example:
d = {"a": "a", "c": "c", "d": "d", "e": "e"}
How would I do this?
Edit:
Implementation code:
def ylimChoice():
#returns all permutations of letter capitalisation in a certain word.
def permLet(s):
return(''.join(t) for t in product(*zip(s.lower(), s.upper())))
inputList = []
yesNo = input('Would you like to set custom ylim() arguments? ')
inputList.append(yesNo)
yes = list(permLet("yes"))
no = list(permLet("no"))
if any(yesNo in str({y: y for y in yes}.values()) for yesNo in inputList[0]):
yLimits()
elif any(yesNo in str({n: n for n in no}.values()) for yesNo in inputList[0]):
labelLocation = number.arange(len(count))
plot.bar(labelLocation, list(count.values()), align='center', width=0.5)
plot.xticks(labelLocation, list(count.keys()))
plot.xlabel('Characters')
plot.ylabel('Frequency')
plot.autoscale(enable=True, axis='both', tight=False)
plot.show()