"list_or_dict must be a list or a dict" when using append in openpyxl package of Python
Question: Based on this tutorial :
[LINK](https://openpyxl.readthedocs.org/en/latest/usage.html) we have this
structure:

    
    
    from openpyxl import Workbook
    from openpyxl.compat import range
    
    wb = Workbook()
    ws = wb.active
    
    for row in range(1,3):
        ws.append(range(100))
    
    wb.save(finename ='mtest2.xlsx')
    

This returns below error for `ws.append(range(100))`:

    
    
    TypeError: list_or_dict must be a list or a dict 
    

What is the problem?


Answer: Evidently the argument to `ws.append` must be either a dictionary or a list.
Presumably you're using Python 3.x, where [`range` no longer returns a
list](https://docs.python.org/3/whatsnew/3.0.html#views-and-iterators-instead-
of-lists) (it now behaves like Python 2.x's `xrange`).

The simplest fix is to explicitly convert the `range` into a `list`:

    
    
    for row in range(1, 3):
        ws.append(list(range(100)))
    

