I'm trying to grab the letters in a string and replace them with an empty space, in this case the empty space is represented by "_" with a space between each underscore.
This is my code:
word = "my example"
def convert_letter(word):
for i in range(0, len(word)):
if ord(word[i]) != 32:
word.replace(word[i], '_')
print(word)
convert_letter(word)
When I run the code it just returns the word or string and I have no idea why.
Just in case you're wondering the purpose of the if statement is so that it doesn't convert the spaces to "_".
So in the case of this function I'm expecting the following:
_ _ _ _ _ _ _ _ _