[Tutor] Tutor Digest, Vol 117, Issue 33[ Re: Ideas ? ]

Satheesan Varier satheesan.varier at gmail.com
Tue Nov 19 03:02:50 CET 2013


Need a little help with finding a process for this:

when a string of text is input, for example: abc def.
I want to have each letter shift to the right one place in the alphabet.
Thus..
abc def would be output as bcd efg.

Any ideas on how to do this?
-------------------------------------------------------------------------
if you do not want to use the translate:

>>> s='abcdef ghijk lmn'
>>> k=''
>>> for char in s:
if char!=' ':
   k+=str(chr(ord(char)+1))
else:
   k+=' '

>>> k
'bcdefg hijkl mno'
--------------------------------------------------------------------------
If you want to use translate:

>>> from string import maketrans
>>> your_alphabets = 'abcdefghijklmnopurstuvwzyz'
>>> my_alphabets='bcdefghijklmnopqystuvwxyza'
>>> s='Let us Test Your language !'

>>> s.translate(maketrans(your_alphabets, my_alphabets))
'Lfu vt Tftu Ypvs mbohvbhf !'

Note: my_alphabets to fine tune
__________________________________________




On Mon, Nov 18, 2013 at 6:00 AM, <tutor-request at python.org> wrote:

> Send Tutor mailing list submissions to
>         tutor at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mail.python.org/mailman/listinfo/tutor
> or, via email, send a message with subject or body 'help' to
>         tutor-request at python.org
>
> You can reach the person managing the list at
>         tutor-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Tutor digest..."
>
>
> Today's Topics:
>
>    1. ideas? (Byron Ruffin)
>    2. Re: Phython List values :p: (Paradox)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 17 Nov 2013 21:27:56 -0600
> From: Byron Ruffin <byron.ruffin at g.austincc.edu>
> To: tutor at python.org
> Subject: [Tutor] ideas?
> Message-ID:
>         <CAOsa8fcmWb_fo38kH6Kxvcwb8n47f3XLqc4c=
> kOJUKEyG+chWw at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Need a little help with finding a process for this:
>
> when a string of text is input, for example: abc def.
> I want to have each letter shift to the right one place in the alphabet.
> Thus..
> abc def would be output as bcd efg.
>
> Any ideas on how to do this?
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/tutor/attachments/20131117/56728ee8/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Mon, 18 Nov 2013 05:49:06 -0500
> From: Paradox <paradox at pobox.com>
> To: tutor at python.org
> Subject: Re: [Tutor] Phython List values :p:
> Message-ID: <5289F0A2.3010306 at pobox.com>
> Content-Type: text/plain; charset=windows-1252; format=flowed
>
> Ayo,
>
> On 11/18/2013 01:57 AM, Ayo Rotibi wrote:
> >
> >
> > I read that an assignment with an = on lists does not make a copy.
> > Instead, assignment makes the two variables point to the one list in
> > memory. For instance, if a = [1, 2, 3] and b=a, then b = [1, 2, 3].
> >
> > However, I discovered that if I change the value in ?a?,  ?b? does not
> > take the new value.  I thought since it is pointing to the same
> > storage as ?a?, ?b? should take the new value?
> >
> >
> It is not clear to me what code you are running, maybe you could give us
> the specifics?  When I run an assignment like you seem to be talking
> about I get the expected result (using ipython for an interactive
> session to demonstrate):
>
> In [1]: a=[1,2,3]
>
> In [2]: b=a
>
> In [3]: b
> Out[3]: [1, 2, 3]
>
> In [4]: a[1]=0
>
> In [5]: a
> Out[5]: [1, 0, 3]
>
> In [6]: b
> Out[6]: [1, 0, 3]
>
> Is that not what you are seeing?  If not perhaps you could show us how
> you are doing the list assignment and changing the list a, what output
> you are expecting and what output you are getting.
>
> thomas
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> https://mail.python.org/mailman/listinfo/tutor
>
>
> ------------------------------
>
> End of Tutor Digest, Vol 117, Issue 33
> **************************************
>



-- 
Warm regards.

Satheesan Varier
860 (970) 2732
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131118/ade83a35/attachment.html>


More information about the Tutor mailing list