Re: [Tutor] How to change the char in string for Python

2013-02-24 Thread Jos Kerc
On Sun, Feb 24, 2013 at 2:26 PM, Sudo Nohup wrote: > Thanks very much!! > > I learnt a lot from you kind reply. Not only is it about the question > itself, but also about how to ask a question in a mailing list.(Sorry that > it is the first time for me to ask questions in a mailing list). > > The

Re: [Tutor] How to change the char in string for Python

2013-02-24 Thread Sudo Nohup
Thanks very much!! I learnt a lot from you kind reply. Not only is it about the question itself, but also about how to ask a question in a mailing list.(Sorry that it is the first time for me to ask questions in a mailing list). The question comes from a riddle of the PythonChallenge website( htt

Re: [Tutor] How to change the char in string for Python

2013-02-24 Thread Dave Angel
Both your later remarks are top-posted, ruining the sequence of who posted what. On 02/24/2013 06:57 AM, Sudo Nohup wrote: Thanks for your help. I just found a webpage used for me: http://stackoverflow.com/questions/10017147/python-replace-characters-in-string That page provides some other so

Re: [Tutor] How to change the char in string for Python

2013-02-24 Thread Steven D'Aprano
On 24/02/13 22:42, Sudo Nohup wrote: Actually, I would like to substitute all the chars in a string with its ascii adding 2, for cracking the naive "Caesar cipher". A shameless plug: https://pypi.python.org/pypi/obfuscate -- Steven ___ Tutor mai

Re: [Tutor] How to change the char in string for Python

2013-02-24 Thread Steven D'Aprano
On 24/02/13 21:56, Sudo Nohup wrote: Dear all, I want to change the value of a char in a string for Python. However, It seems that "=" does not work. Strings are immutable, which means that you cannot modify them in place. You can only create a new string with the characters you want. If yo

Re: [Tutor] How to change the char in string for Python

2013-02-24 Thread Sudo Nohup
Thanks for your help. I just found a webpage used for me: http://stackoverflow.com/questions/10017147/python-replace-characters-in-string That page provides some other solutions. Thanks! On Sun, Feb 24, 2013 at 7:47 PM, Asokan Pichai wrote: > On Feb 24, 2013 4:27 PM, "Sudo Nohup" wrote: > > >

Re: [Tutor] How to change the char in string for Python

2013-02-24 Thread Asokan Pichai
On Feb 24, 2013 4:27 PM, "Sudo Nohup" wrote: > > Dear all, > > I want to change the value of a char in a string for Python. However, It seems that "=" does not work. > > Could you help me? Thanks! > > str = "abcd" > result = [char = 'a' for char in str if char == 'c'] > > > OR: > > str = 'abcd' >

Re: [Tutor] How to change the char in string for Python

2013-02-24 Thread Sudo Nohup
Actually, I would like to substitute all the chars in a string with its ascii adding 2, for cracking the naive "Caesar cipher". So, there is a list of chars to be replaced. If I use "replace" function, I have to replace them one by one. Thanks all the same. On Sun, Feb 24, 2013 at 7:32 PM, Marc

[Tutor] How to change the char in string for Python

2013-02-24 Thread Sudo Nohup
Dear all, I want to change the value of a char in a string for Python. However, It seems that "=" does not work. Could you help me? Thanks! str = "abcd" result = [char = 'a' for char in str if char == 'c'] OR: str = 'abcd' for char in str: if char == 'a': char = 'c' OR: str = 'a