I am writing a simple Python script that retrieves the latest tweet of any twitter user (in this case BBC) and uses the integrated text-to-speech system on Mac to read out the content of that particular tweet.
Everything is running as it should, but there are certain things I want to improve. For instance, if a tweet contains the character "#", the computer will speak this as "number". E.g, if the tweet were to read "#BBC covers the latest news", the computer speaks "number BBC covers the latest news".
I have declared a string to hold the content of the tweet, and wish to find a way to replace unwanted characters with white spaces. So far, I have the following:
for char in data_content: #data_content is the string holding the tweet
if char in "#&/": # does not replace #
mod_data = data_content.replace(char, '')
print(mod_data)
system('say ' + mod_data)
This seems to be working correctly with the "/" character, but does not replace the "#" character. So, any help on this matter is very much appreciated!
P.S. I have tried replacing the "#" character alone, in which case I get the desired result. However, when I try to provide a series of characters to replace, it only replaces the "/" character.
Thanks!