Having a really silly problem. I'm iterating over a string and removing all non-alphabetical characters. The problem is that when I remove them, the length of the string decreases and my loop crashes because I go out of bounds.
for x in s:
if x.isalpha() == False:
s = s.replace(x, "")
sreally is a string, this will not crash, whatever that means. The code you posted will work and produce the intended result both on Python 2 and Python 3. It is however very inefficient.