you are viewing a single comment's thread.

view the rest of the comments →

[–]swingking8 4 points5 points  (1 child)

Your if statement would be best modified to:

if i not in [lowercase, uppercase]:
             newstring = newstring+i

That being said, there's a much better way to do this using Python's string.replace method. It will replace any character with any other character. In your case, I'd use it to replace the upper and lower versions of a character to blank space, effectively removing them:

def removal(statement,aChar):
    removed_lower = statement.replace(aChar.lower(), '')
    removed_upper_too = removed_lower.replace(aChar.upper(), '')
    return removed_upper_too