[Baypiggies] string question
Simeon Franklin
simeonf at gmail.com
Tue Apr 5 22:39:07 CEST 2011
On Tue, Apr 5, 2011 at 1:25 PM, Vikram K <kpguy1975 at gmail.com> wrote:
> Given a string and some indices, how do i change upper characters
> corresponding to some position(s) in the string to lower characters? I tried
> and failed.
>
> Copy'n'paste from my ipython console:
In [1]: x = 'EPSPVRYDNLSR'
In [2]: z = [2, 6]
# Convert string to list to modify it
In [3]: x = [i for i in x]
In [4]: x
Out[4]: ['E', 'P', 'S', 'P', 'V', 'R', 'Y', 'D', 'N', 'L', 'S', 'R']
In [5]: for i in z:
...: x[i] = x[i].lower()
...:
In [6]: x = ''.join(x)
In [7]: x
Out[7]: 'EPsPVRyDNLSR'
-regards
Simeon Franklin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20110405/ff8b7a68/attachment-0001.html>
More information about the Baypiggies
mailing list