Skip to content
Advertisement

Using eval in the middle of a python statement

I want to use eval in the middle of the following python statement:

JavaScript

but because it does not return any value (it works in an “in place” manner), I cannot actually use it there and instead I receive an error of TypeError: can only concatenate list (not "NoneType") to list . Is there any way that I can fix this issue by getting return value out of eval in Python?

Advertisement

Answer

You can use list concatenation instead of calling append(). It returns the new list.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement