Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #56424

Re: converting letters to numbers

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!eweka.nl!hq-usenetpeers.eweka.nl!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <random832@fastmail.us>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.041
X-Spam-Evidence '*H*': 0.92; '*S*': 0.00; 'received:internal': 0.09; 'def': 0.12; 'ans': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'together.': 0.24; 'header:In-Reply- To:1': 0.27; 'to:2**1': 0.27; 'to:no real name:2**1': 0.29; "skip:' 10": 0.31; 'subject:numbers': 0.31; 'sense': 0.34; 'received:66': 0.35; 'doing': 0.36; 'received:10': 0.37; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'from:no real name:2**0': 0.61; 'header:Message-Id:1': 0.63; 'email addr:gmail.com': 0.63; 'to:addr:gmail.com': 0.65; 'results': 0.69; '2013,': 0.91
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:from:to:mime-version:content-transfer-encoding :content-type:in-reply-to:references:subject:date; s=mesmtp; bh= CBbl/e+IqTHTyWLREgvqyqFh5XU=; b=YXgl5CXWtRGntN2ZgRetbUQk9NCEuf1n L+kPesk9reXpDkSN24mzzjSlGX4t6+NMeHrr1vpZdQQPf89IJ//uM2hKLZdvifdO 2ZuOr06cFl7cykQTbcXG8yU2SoUEVBQc+YP6/qmL4S7wYdUouqiTjlyMfErAx12U TKdC7BZhAqc=
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=smtpout; bh=CBbl/e+IqTHTyWLREgvqyqFh5XU=; b=f2j BJN4FbaWziA+olD5Y9CQ5IJYGlAFzkk0DsKDPfrNH/arAyfLOvtXAy+bYiVaRvlU cdxHOJvCzawCqadltQ/AZpodjZz6liFigKl/Fkf+zxhijNkwTOncxkPCeN3l4ZPQ Vby6Jg6O3Trgqb68LaANSayROxcVtgIZAvuVp5+U=
X-Sasl-Enc nsN54VjqxvIveLn9HUkkcDlwVN/KIOEmQG8FPhhSL7// 1381247916
From random832@fastmail.us
To kjakupak@gmail.com, python-list@python.org
MIME-Version 1.0
Content-Transfer-Encoding 7bit
Content-Type text/plain
X-Mailer MessagingEngine.com Webmail Interface - ajax-ce174988
In-Reply-To <fb210bab-7ea2-4c70-93e0-7f111d794b72@googlegroups.com>
References <26151b64-4f5e-4ee9-81ac-26679932f43d@googlegroups.com> <mailman.859.1381246619.18130.python-list@python.org> <fb210bab-7ea2-4c70-93e0-7f111d794b72@googlegroups.com>
Subject Re: converting letters to numbers
Date Tue, 08 Oct 2013 11:58:36 -0400
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.861.1381247920.18130.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1381247920 news.xs4all.nl 15881 [2001:888:2000:d::a6]:34510
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:56424

Show key headers only | View raw


On Tue, Oct 8, 2013, at 11:44, kjakupak@gmail.com wrote:
> def add(c1, c2):
>     ans = ''

This only makes sense if your answer is going to be multiple characters.

>     for i in c1 + c2:

This line concatenates the strings together.

>         ans += chr((((ord(i)-65))%26) + 65)

The way you are doing the modulus, this results in - well, let me
illustrate:

>>> add('','WXYZ[\]^_`abcde')
'WXYZABCDEFGHIJK'

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

converting letters to numbers kjakupak@gmail.com - 2013-10-08 07:28 -0700
  Re: converting letters to numbers Robert Day <robertkday@gmail.com> - 2013-10-08 15:47 +0100
    Re: converting letters to numbers kjakupak@gmail.com - 2013-10-08 07:51 -0700
      Re: converting letters to numbers Joel Goldstick <joel.goldstick@gmail.com> - 2013-10-08 11:01 -0400
  Re: converting letters to numbers random832@fastmail.us - 2013-10-08 11:36 -0400
    Re: converting letters to numbers kjakupak@gmail.com - 2013-10-08 08:44 -0700
      Re: converting letters to numbers random832@fastmail.us - 2013-10-08 11:58 -0400
      Re: converting letters to numbers Tim Roberts <timr@probo.com> - 2013-10-13 20:13 -0700
        Re: converting letters to numbers Steven D'Aprano <steve@pearwood.info> - 2013-10-14 05:02 +0000
          Re: converting letters to numbers Charles Hixson <charleshixsn@earthlink.net> - 2013-10-16 12:18 -0700
            Re: converting letters to numbers Piet van Oostrum <piet@vanoostrum.org> - 2013-10-16 16:25 -0400
          Re: converting letters to numbers Rotwang <sg552@hotmail.co.uk> - 2013-10-16 23:39 +0100
            Re: converting letters to numbers MRAB <python@mrabarnett.plus.com> - 2013-10-16 23:53 +0100
            Re: converting letters to numbers Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-10-17 01:21 +0100
          Re: converting letters to numbers Tim Roberts <timr@probo.com> - 2013-10-19 16:31 -0700
          Re: converting letters to numbers rusi <rustompmody@gmail.com> - 2013-10-20 01:33 -0700
  Re: converting letters to numbers Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-08 17:05 +0100
  Re: converting letters to numbers Dave Angel <davea@davea.name> - 2013-10-08 21:24 +0000

csiph-web