title: remove numbers string python
body: <p>For my assignment, I have to create a function that returns a new string that is the same as the given string, but with digits removed.</p>
  
  <p>Example: remove digits(’abc123’) would return the string ’abc’.</p>
  
  <p>I have tried almost everything I can think off but it's not working properly :(</p>
  
  <pre><code>def test(str):
      for ch in str:
          num = ['0', '1', '2', '3', '4', '6', '7', '8', '9']
          if ch == num[0]:
              return str.replace(ch, '')
          elif ch == num[1]:
              return str.replace(ch, '')
          elif ch == num[2]:
              return str.replace(ch, '')
          elif ch == num[3]:
              return str.replace(ch, '')
          elif ch == num[4]:
              return str.replace(ch, '')
          elif ch == num[5]:
              return str.replace(ch, '')
          elif ch == num[6]:
              return str.replace(ch, '')
          elif ch == num[7]:
              return str.replace(ch, '')
          elif ch == num[8]:
              return str.replace(ch, '')
  </code></pre>
  
  <p>I enter test('abc123'), expecting the output to be 'abc'. But instead I get 'abc23' as my output. </p>
  
  <p>In other attempts, same problem:</p>
  
  <pre><code>def test(str):
      for char in str:
          num = ['0', '1', '2', '3', '4', '6', '7', '8', '9']
          if char in list(num):
              return str.replace(char, '', len(str))
  </code></pre>
  
  <p>I get the same results. </p>
  
  <p>Can anyone help me? It would be greatly appreciated. </p>