+ 1
Could someone explain what this does and how ?
s="string" s= s[:1] + s[1:]
2 odpowiedzi
+ 10
[start : end : step]
is the pythonic way of slicing strings , lists, etc...
[:1] = [0:1:1]
[1:] = [1:end:1]
In your given code
it does nothing just slice and join it back to the same thing
s[:1] = "s"
s[1:] = "tring"
s = "s" + "tring"
it works same as it works on lists 👇
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2453/?ref=app
+ 1
Thanks