Skip to content
Advertisement

Replace string in a list using python and save it with different variable

I am trying to replace a string with another string in a list, but failed and I don’t know why.

For example, I have a list:

JavaScript

i want to replace __label__1 with “OK” and __label__0 with “NOT OK” and save it in different variable using :

JavaScript

but it failed to replace any of it

Advertisement

Answer

The predicts variable has two dimensions, try:

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