I'm trying to use the count and replace string methods to count and then replace (more so remove) specific singular characters (ex, 'a' by itself) or words (ex, 'the'), but not every instance of that character. (ex, I do not want to replace a with nothing, and cause the word character to become chrcter)
my_string = 'a and the and a character and something but not a something else.'
I know this isn't really necessary, but I just wanted to find out how many instances of a I needed to replace with the replace call.
print(my_string.count('a'))
my_string = my_string.replace('a', '', 8)
print(my_string)
so clearly here I'm hoping that it would just remove the lone a's, but as indicated by the returned count number, and actually running the program, it simply removes all of the a characters from the program.