title: Changing lowercase characters to uppercase and vice-versa in Python
body: <p>I'm trying to write a function which given a string returns another string that flips its lowercase characters to uppercase and viceversa.</p>
  
  <p>My current aproach is as follows:</p>
  
  <pre><code>def swap_case(s):
      word = []
      for char in s:
          word.append(char)
  
      for char in word:
          if char.islower():
              char.upper()
          else:
              char.lower()
  
      str1 = ''.join(word)
  </code></pre>
  
  <p>However the string doesn't actually change, how should I alter the characters inside the loop to do so?</p>
  
  <p>PS: I know s.swapcase() would easily solve this, but I want to alter the characters inside the string during a for loop.</p>