human
Write me a the Python code you requested given the following:
Write a function to replace whitespaces with an underscore and vice versa in a given string. Here is a solution in Python:
assistant
#Here is the Python code you requested.
 def replace_spaces(text):
  return "".join(" " if c == "_" else ("_" if c == " " else c) for c in text)