Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.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.064 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.01; 'from:addr:yahoo.co.uk': 0.04; 'encoding': 0.05; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; 'ord': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'red,': 0.16; 'spacing': 0.16; 'wrote:': 0.18; 'later': 0.20; 'header:User-Agent:1': 0.23; 'url:moin': 0.24; 'define': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'converting': 0.30; 'url:wiki': 0.31; 'mod': 0.31; 'subject:numbers': 0.31; 'url:python': 0.33; "i'd": 0.34; 'requirement': 0.35; 'but': 0.35; 'replies': 0.36; "i'll": 0.36; 'url:org': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'letters': 0.60; 'most': 0.60; 'eye': 0.61; "you're": 0.61; 'further': 0.61; 'back': 0.62; 'email addr:gmail.com': 0.63; 'sum': 0.64; 'here': 0.66; '26,': 0.68; 'capital': 0.73; 'contagious,': 0.84; 'how.': 0.84; 'medication': 0.84; 'strain': 0.84; 'severe': 0.91; 'suffering': 0.93; 'purchasing': 0.97 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: converting letters to numbers Date: Tue, 08 Oct 2013 17:05:33 +0100 References: <26151b64-4f5e-4ee9-81ac-26679932f43d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-78-147-16-137.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0 In-Reply-To: <26151b64-4f5e-4ee9-81ac-26679932f43d@googlegroups.com> 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: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1381248347 news.xs4all.nl 15890 [2001:888:2000:d::a6]:43190 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:56428 On 08/10/2013 15: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). > I'd say the requirement is lacking in that no encoding is specified. > 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. > I'll further observe from your later replies that you're suffering from the highly contagious, highly virulent double line spacing disease. This is known to cause severe eye strain leading to blindness. In can be cured by purchasing medication here https://wiki.python.org/moin/GoogleGroupsPython -- Roses are red, Violets are blue, Most poems rhyme, But this one doesn't. Mark Lawrence