New contribution to Python built-in libraries.
"Kiruthik.M.R 11-B" <[email protected]> Sat, 27 Aug 2022 22:23:57 +0530
| Newsgroups | gmane.comp.python.devel |
|---|---|
| Message-ID | <CAKqEbwPhrQvq5=EyYFQpQQOrDZ_Qqe4kN3+x553yHdNe7DLi=w@mail.gmail.com> |
Greetings, I'm Kiruthik from India. I've been studying coding for the past two years. I know that strings are immutable in Python. But, most of the people can't change the elements in the string as default. So, I came up with a solution by creating a function called *strangelt. *This function has three parameters in it and works faster. It has the ability to get a string from the user and make changes to the element of the string using index values. I found that it would be a pretty good solution for people's problems. I hereby kindly request you to include this function in Python built-in libraries from the release of the next version. Expansion of strangelt: *str*ing+ch*ang*e+*el*ement *Syntax:* *string_variable=strangelt(string,index,new value to be replaced)* Thank You, Kiruthik.
StringChangeElementFunctionPython.txt
(text/plain, 134 B)
def strangelt(s,j,m):
l=[]
for i in s:
if(i==s[j]):
i=m
l.append(i)
return(''.join(l))
StringChangeElementFunctionPython.py
(text/x-python, 134 B)
def strangelt(s,j,m):
l=[]
for i in s:
if(i==s[j]):
i=m
l.append(i)
return(''.join(l))