How to convert a list to a dictionary where both key and value are the same?
<p>This is based on this question: <a href="http://stackoverflow.com/questions/6900955/python-convert-list-to-dictionary">python convert list to dictionary</a></p>

<p>The asker provides the following:</p>

<blockquote>
<pre><code>l = ["a", "b", "c", "d", "e"]
</code></pre>
  
  <p>I want to convert this list to a
  dictionary like:</p>

<pre><code>d = {"a": "b", "c": "d", "e": ""}
</code></pre>
</blockquote>

<p>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:</p>

<pre><code>d = {"a": "a", "c": "c", "d": "d", "e": "e"}
</code></pre>

<p>How would I do this? </p>

<hr>

<p><strong>Edit</strong>:</p>

<p>Implementation code: </p>

<pre><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()
</code></pre>

<p>You can use a <a href="https://docs.python.org/2/tutorial/datastructures.html#dictionaries" rel="nofollow">dict-comprehension</a> like this:</p>

<pre><code>l = ["a", "b", "c", "d", "e"]
d = {s: s for s in l}
</code></pre>

python python-3.x dictionary