I am looking for a way to replace a word, however only when its not surounded by quotations.
For example Replacing Hello with Hi
Hello
Hi
Consider using a regular expression (not the only way, but I'd go with that).
In [2]: print s Hello 'Hello' Nothing In [3]: import re In [4]: re.sub("(?