+ 1
+= operator not working
Hello everyone! Could someone help me with this little code, please? I can't find my mistake. Thanks you guys! https://code.sololearn.com/cJLPk1i4KHq4/?ref=app
7 Answers
+ 1
name[0,1]+="o" Is equal to,
name[0, 1]=name[0, 1]+"o" ,
There is nothing like "0, 1" That python supports .
+ 1
ā²TopGun ā² didn't understand what you mean but you can't do ,
name[1, 0] =name[1, 0]
. It is like developing your own way and hoping that it will work ,python don't know how to interpret whatever you were trying to do.
0
Thanks for your answer Jan Markus [PRO_crastinator]
Although it makes my life much harder. I didn't understand almost anthing you done.
What's wrong with that:
x = 'nynme'
x = x[0,2] += 'a'
Expected output: 'anyname'.
0
I don't do that Abhay , didn't I ?
0
Abhay let's keep it simple. I know you are trying to help me. Please, how would you fill this [with a simple Python code]
name = SloLern
#Add two letter in different positions in name
Output expected: SoloLearn
That's what I'm trying to do.
I had looked up and find that "+=" just work with numbers. I would like to "some", actually, include strings.
Could someone help me, please?
0
Oooh! Okay.
Now, I got it.
I can work with a string, just strings are changeable. Am I right?
So, in this case..
def convert_function(x):
empty=""
return (empty.join(x))
name =list(input())
#Let's assume the input is 'nynme'
name[0,3]+='a'
print(convert_function(name))