Skip to content
Advertisement

How to take the item from string and use it as a value

I have a string and I need to use this string to fit a model. However when I try try to do this, of course it raises an error which can be seen below. How can I use this string to fit the model?

JavaScript

Advertisement

Answer

You need to evaluate the string into a Python object, ie do

JavaScript

See documentation of eval() https://docs.python.org/3/library/functions.html#eval

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