Remove function error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

20th May 2018, 3:02 AM
...
... - avatar
4 Answers
20th May 2018, 8:54 AM
Maninder $ingh
Maninder $ingh - avatar
+ 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.
20th May 2018, 3:55 AM
$ยข๐Žโ‚น๐”ญ!๐จ๐“
$ยข๐Žโ‚น๐”ญ!๐จ๐“ - avatar
+ 1
I think no need to use while loop too, because replace method can replace multiple occurrences. word=input(' ') word = word.replace('@','') print (word)
20th May 2018, 8:08 AM
$ยข๐Žโ‚น๐”ญ!๐จ๐“
$ยข๐Žโ‚น๐”ญ!๐จ๐“ - avatar
+ 1
Ok I get it thanks everyone!!
20th May 2018, 12:10 PM
...
... - avatar