+ 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

4th Mar 2021, 4:46 PM
▲TopGun ▲
▲TopGun ▲ - avatar
7 odpowiedzi
+ 1
name[0,1]+="o" Is equal to, name[0, 1]=name[0, 1]+"o" , There is nothing like "0, 1" That python supports .
4th Mar 2021, 5:04 PM
Abhay
Abhay - avatar
+ 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.
4th Mar 2021, 11:10 PM
Abhay
Abhay - avatar
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'.
4th Mar 2021, 10:42 PM
▲TopGun ▲
▲TopGun ▲ - avatar
0
I don't do that Abhay , didn't I ?
4th Mar 2021, 10:43 PM
▲TopGun ▲
▲TopGun ▲ - avatar
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?
5th Mar 2021, 3:31 AM
▲TopGun ▲
▲TopGun ▲ - avatar
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))
5th Mar 2021, 4:28 AM
▲TopGun ▲
▲TopGun ▲ - avatar