please help me: i need add characteres in strings x=" " x add h e l l o letter by letter x="hello"
exist any function
Yes, the += operator is overloaded to include adding strings together. Since you strings, h, e, l, l, and o, are just one character each; your code should look like this: x = "" x += "h" x += "e" x += "l" x += "l" x += "o" print x
thanks but i need add in positions x[i]
abc="abcdefghijklmnopqrstuvwxyz" def letrad(ltr,abc): m="" z="_" for i in range(len(abc)): if abc[i]==ltr: m= m + z[0] else: m=m + abc[i] return m letrad("u",abc)
for example but without "-"
As far as I know strings are immutable in Python, but you can do things like this: x="hello" print x x=x[:4]+' n'+x[4:] #this being what I think you want print x
Join our real-time social learning platform and learn together with your friends!