Ask coding questions

← Back to all posts
Issue with lists and "observed lists"
JasmineSaliba (0)

If anyone has gotten this error below, how did you fix it?
Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/", line 343, in _run_event
await coro(*args, **kwargs)
File "", line 58, in on_message
options = options + encourge_options
TypeError: can only concatenate list (not "ObservedList") to list

Answered by VulcanWM (2912) [earned 5 cycles]
View Answer
VulcanWM (2912)

Apparently either encourage_options or options is an “ObservedList” and you cannot add a list to an observed list.
Try converting the “ObservedList” to a list by using the list() function

Coder100 (18939)

Replit db actually extends on the list object, so what they return is not what python list really is.

Here is what I recommend doing:

arr = db['... list ...']
arr.append(... whatever ...)
db['... list ...'] = arr