title: Racket Error: expects a non-empty list but given empty
body: <p>I'm writing a program where it asks me to convert all the uppercase letters in str to lowercase and lowercase to uppercase, and all other characters remain the same.
  Below is my code:</p>
  
  <pre><code>(define (switch-case str)
    (list-&gt;string (switch-char (string-&gt;list str))))
  
  (define (switch-char loc)
     (cons
      (cond
        [(empty? (first loc)) empty]
        [(char-lower-case? (first loc)) (char-upcase (first loc))]
        [(char-upper-case? (first loc)) (char-downcase (first loc))]
        [else (first loc)]) (switch-char (rest loc))))
  </code></pre>
  
  <p>And the error message for (switch-case "ABC") is:</p>
  
  <blockquote>
    <p>first: expects a non-empty list; given: empty</p>
  </blockquote>
  
  <p>Can someone help me with this? I don't know which part of the code is wrong:(</p>