How to use string value as a variable name in Python?
<p>Suppose I have lists as follows:</p>

<pre><code>candy = ['a','b','c']
fruit = ['d','e','f']
snack = ['g','h','i']
</code></pre>

<p>and a string</p>

<pre><code>name = 'fruit'
</code></pre>

<p>I want to use string <code>name</code> for accessing list and it's content. In this case it should be <code>fruit</code>. I will use <code>name</code> for iterating list. As:</p>

<pre><code>for x in name:
    print x
</code></pre>