Replace function will not recognise second argument

Hi, I’m trying to use a replace function as part of this exercise

jeopardy.Value= jeopardy.Value.apply(str.replace('$' , ''))

I’m trying to replace a dollar sign with an empty string to remove it, but the code gives me this error message.

Traceback (most recent call last):
  File "", line 33, in <module>
    jeopardy.Value= jeopardy.Value.apply(str.replace('$' , ''))
TypeError: replace() takes at least 2 arguments (1 given)

I’ve tried many different arguments, but they all throw up the same error, It won’t recognise that I’ve input two arguments. Does anyone know what’s wrong? Thanks in advance.

You’d want to be using the .replace method on a particular string instance rather than with the str class itself.

'a string'.replace('a', 'b')  # would return 'b string'
1 Like