Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: 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; "'a'": 0.09; 'received:internal': 0.09; 'def': 0.12; 'i.e.,': 0.16; 'lowercase': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'ord': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.44': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:compute4.internal': 0.16; 'received:messagingengine.com': 0.16; 'wrote:': 0.18; 'define': 0.26; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'function': 0.29; 'to:no real name:2**1': 0.29; 'converting': 0.30; 'letter.': 0.31; 'mod': 0.31; 'subject:numbers': 0.31; 'says': 0.33; 'received:66': 0.35; 'basic': 0.35; 'but': 0.35; 'should': 0.36; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'letters': 0.60; 'from:no real name:2**0': 0.61; 'back': 0.62; 'header:Message- Id:1': 0.63; 'email addr:gmail.com': 0.63; 'sum': 0.64; 'to:addr:gmail.com': 0.65; '26,': 0.68; 'capital': 0.73; 'how.': 0.84; '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= mdnK4vG2dmrMrNP6OkYwknIK9lc=; b=C0ZSpTnWk370h8KXTBeZK9swnuGlZbZ/ 3GTgvN7UJXJyNyBHJnRZaXBS4I+umkKZuxvZm/bLORvnO/UTx9BIDyCj8fD4tgh3 Pwpnyy6oRVbAFrFw6NmS2qJj1DG0gw3EbILNmKQK1kA4JkXfpP8BiKEvVtDpypdn a7iA71bQxTo= 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=mdnK4vG2dmrMrNP6OkYwknIK9lc=; b=c2A UnXE7HmAsFMFQ0UjxWb9nUVTcc99MoqWOMZMEKYcM45N5pIKegwMbMkLMjsUaJd5 ms4bSbdwllzqqldrbVA/RvlFfL68vg84J/m0Im7L79kzN3QSJ9eBq17FyCyqz/gS mSRX0iqMAJ+fDuF3AfqBYvQTLapjiyySFbie7rAw= X-Sasl-Enc: xzKJyU2y/XJtmZnZq7xXuv2W9lNJDS0B28j6Py/3W3Z3 1381246611 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: <26151b64-4f5e-4ee9-81ac-26679932f43d@googlegroups.com> References: <26151b64-4f5e-4ee9-81ac-26679932f43d@googlegroups.com> Subject: Re: converting letters to numbers Date: Tue, 08 Oct 2013 11:36:51 -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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381246619 news.xs4all.nl 15866 [2001:888:2000:d::a6]:43589 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56418 On Tue, Oct 8, 2013, at 10:28, kjakupak@gmail.com wrote: > I have to define a function add(c1, c2), where c1 and c2 are capital > letters; the return value should be the sum (obtained by converting the > letters to numbers, adding mod 26, then converting back to a capital > letter). > > All I have so far is: > > def add(c1, c2): > ord(c1) - ord('a') + 1 > ord(c2) - ord('a') + 1 > > I know I need to use ord and chr, just not sure how. Your description says capital letters, but 'a' is a lowercase letter. Does "mod 26" means A is 1, or is it 0? i.e., is A+A = B or is it A? What should your function do if the letter isn't a capital letter from the basic set of 26 English letters?