+ 2
Remove function error
So I used the count function to extract an object from a list, because I was trying to write a program to remove @ symbols from a phrase, and then I tried to use the remove function on the object and it says the error, ’str has no object to attribute’ or something like that. https://code.sololearn.com/cCKzvSud6l9J/?ref=app
4 Respostas
+ 2
Jack your right code.
https://code.sololearn.com/c9eWD7OfHOHO/?ref=app
+ 1
hey jack,
here you go,
word=input(' ')
print ("Word = ",word)
while word.count('@') != 0:
word = word.replace('@','')
print (word)
input is always in string, so no need of str explicitly.
Also if you want to process on string than no need of creating list.
+ 1
I think no need to use while loop too, because replace method can replace multiple occurrences.
word=input(' ')
word = word.replace('@','')
print (word)
+ 1
Ok I get it
thanks everyone!!