title: Create Optionmenu with for loop
body: <p>I am pretty new to Python as well as coding in general.</p>
  
  <p>I've got 42 Labels (Strings) stored in a list. 
  My aim is to: for each of the 42 labels, create a Tkinter Label displaying the String and a Dropdown List (Tkinter Optionmenu).</p>
  
  <p><strong>Two problems</strong> occur:</p>
  
  <ul>
  <li>I get an index error for the list of variables (for the optionmenus), here is the output of my Console:
  
  <blockquote>
    <p>varDd[i] = StringVar(root)
    IndexError: list assignment index out of range</p>
  </blockquote></li>
  <li>The Canvas is Scrollable as I intended, but the content doesn't scroll with it</li>
  </ul>
  
  <p>My complete Code:
  <a href="https://codepaste.net/6jkuza" rel="nofollow noreferrer">https://codepaste.net/6jkuza</a></p>
  
  <p>The <strong>essential part</strong>:</p>
  
  <pre><code>def createDdList():    
      del labelsDd[:]
      del listsDd[:]
          if len(labels) &gt; 1:
              varDd = [len(labels)]
              for i,label in enumerate(labels):
  #               Erstelle Labels mit den Markerlabels im scrollbaren Canvas
                  labelsDd.append(Label(contentCanvas,text=label))
                  labelsDd[i].pack()
  #               Erstelle die Dropdown Listen im scrollbaren Canvas
                  varDd[i] = StringVar(root)
                  listsDd.append(OptionMenu(canvas,varDd[i],*labels))  
                  listsDd[i].place(x=70,y=10+(30*i))
  
  contentCanvas = Frame(canvas,bg='#FFFFFF')
  canvas.create_window((0,375),window=contentCanvas)
  </code></pre>