+ 3

Error in python

I have written a code in python but it keeps on sayings that you can't add two strings. Please help me figure out the bug. https://code.sololearn.com/cINf99vkP9TX/?ref=app

27th Jul 2018, 12:23 PM
Sahil Danayak
Sahil Danayak - avatar
10 ответов
+ 5
https://code.sololearn.com/c57lHpPn34Xd/?ref=app This code works in general no matter where that character is.
27th Jul 2018, 12:30 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
You can't use the minus operator in strings, that's just how strings work
27th Jul 2018, 12:24 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
To remove the character, you can do: string.replace(character,"")
27th Jul 2018, 12:27 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 4
Lucky Luke Yours is a specific case here. Suppose you want to remove any character once, we need better code
27th Jul 2018, 12:28 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 3
You are trying to substract 2 strings, which is not possible.
27th Jul 2018, 12:24 PM
giannismach
giannismach - avatar
+ 3
thanks
27th Jul 2018, 12:26 PM
Sahil Danayak
Sahil Danayak - avatar
+ 2
Here is a working version of your code which removes the first letter of a string. https://code.sololearn.com/cH7zt2I3e26B/?ref=app
27th Jul 2018, 12:27 PM
giannismach
giannismach - avatar
+ 2
Dark Angel you are right, replace is more general.
27th Jul 2018, 12:30 PM
giannismach
giannismach - avatar
+ 2
thanks a lot
27th Jul 2018, 12:31 PM
Sahil Danayak
Sahil Danayak - avatar
+ 2
I also figured out to convert them to lists and then subtract them
27th Jul 2018, 12:31 PM
Sahil Danayak
Sahil Danayak - avatar