Write a function removeLetter(word, letter) that takes in a word and a letter as arguments and remove all the occurrence of that particular letter from the word. The function will returns the remaining leters in the word. Here is my first version
def removeLetter(word, letter):
word=list(word)
for x in word :
if x==letter:
word.remove(x)
return "".join(str(x) for x in word)
print( removeLetter("apple", "p"))
if i use another variable for word for example word1 it works perfectly but what is the reason ?
def removeLetter(word, letter):
word1=list(word)
for x in word :
if x==letter:
word1.remove(x)
return "".join(str(x) for x in word1)
print( removeLetter("applepie", "p"))