title: How to write information from a list to a csv file using csv DictWriter?
body: <p>Using the <code>csv</code> module , Ive been trying to pass / write information from a list  to a csv file  in <code>python</code>using the dictwriter and im getting a strange error , witch will be under the actual code. I want to know whats , the error in the code , and how can we fix it.</p>
  <pre><code>import csv 
  
  names = ['kisha' ,'smith'  , 'kishasmith@gmail.com', 40000  ,  '1-1-2029'   ,'janitor' ]
  
  with open('employees.csv' , 'w')as employee_file:
       fieldnames2 = ['first' , 'last' , 'email' , 'salary' , 'DOB' , 'occupation']
       csvwriter = csv.DictWriter(employee_file , fieldnames = fieldnames2 , delimiter = ',')
       csvwriter.writeheader()
       for info in names:
          csvwriter.writerow(info)
  </code></pre>
  <p>Ive seen other questions related to this topic but nun are applicable to me.</p>
  <h1>ERROR:</h1>
  <pre><code>Traceback (most recent call last):
    File &quot;C:\Users\Kxrk\Downloads\Codes\Employee project\new.py&quot;, line 10, in &lt;module&gt;
      csvwriter.writerow(info)
    File &quot;C:\Users\Kxrk\AppData\Local\Programs\Python\Python36-32\lib\csv.py&quot;, line 155, in writerow
      return self.writer.writerow(self._dict_to_list(rowdict))
    File &quot;C:\Users\Kxrk\AppData\Local\Programs\Python\Python36-32\lib\csv.py&quot;, line 148, in _dict_to_list
      wrong_fields = rowdict.keys() - self.fieldnames
  AttributeError: 'str' object has no attribute 'keys'
  [Finished in 0.1s]
  </code></pre>