[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

TypeError: unhashable type: 'list'

joseph pareti wrote:

> I am experimnenting with this (reproducer) code:
> pattern_eur    = ['Total amount']

Make that 

pattern_eur = 'Total amount'

>    match_C =, element)

The first argument to should be a string, not a list of strings:

>>> import re
>>>"foo", "bar")
>>>["foo"], "bar")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.4/", line 170, in search
    return _compile(pattern, flags).search(string)
  File "/usr/lib/python3.4/", line 282, in _compile
    p, loc = _cache[type(pattern), pattern, flags]
TypeError: unhashable type: 'list'

>     element = element + 2

This will be your next problem; you are adding 2 to a string.