title: How can I invert (swap) the case of each letter in a string?
body: <p>I am learning Python and am working on this exercise:</p>
  <blockquote>
  <p>Create a function that will return another string similar to the input string, but with its case inverted. For example, input of &quot;Mr. Ed&quot; will result in &quot;mR. eD&quot; as the output string.</p>
  </blockquote>
  <p>My code is:</p>
  <pre><code>name = 'Mr.Ed'
  name_list = []
  
  for i in name:
      if i.isupper():
          name_list.append(i.lower())
      elif i.islower():
          name_list.append(i.upper())
      else:
          name_list.append(i)
  
      print(''.join(name_list))
  </code></pre>
  <p>Is there a simpler or more direct way to solve it?</p>