Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:error': 0.03; 'syntax': 0.04; 'string.': 0.05; 'element': 0.07; '22,': 0.09; 'append': 0.09; 'immutable': 0.09; 'item.': 0.09; 'lst': 0.09; 'throws': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; '"a"': 0.16; 'curve.': 0.16; 'dictionaries': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'trying': 0.19; 'value.': 0.19; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'character': 0.29; 'converting': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'changed.': 0.31; 'keys': 0.31; 'second,': 0.31; 'tuples': 0.31; 'lists': 0.32; 'url:python': 0.33; "can't": 0.35; 'received:google.com': 0.35; 'url:listinfo': 0.36; 'doing': 0.36; 'useful': 0.36; 'url:org': 0.36; 'should': 0.36; 'list': 0.37; 'list.': 0.37; 'pm,': 0.38; 'called': 0.40; 'url:mail': 0.40; 'letters': 0.60; 'establish': 0.61; 'numbers': 0.61; 'first': 0.61; 'show': 0.63; 'skip:n 10': 0.64; 'phone': 0.66; 'here': 0.66; 'joel': 0.91; 'subject:Lists': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=zniScarO+MZrqK4iPJDCcaZ+oKR4+Rcm/eSq43b4WT0=; b=ZNTQK2YPPzKNbot1lG6gLaFvjsDyNn9H3en1bDB6RDBOoYE5riaeAuHDnj6X2qrFMJ HITINY/Wb3OP5s/8IPWDMlBtkGIIdA7yDypSVt/suxnhzpQuTKbv683uv59bPo9x0Q7l 9fMm/ma1354khbpGaxPZpcWtSLpYEZEpoGc5TE43TIiihXduS+ZswgfHsAey+kPBJ9VU fddwFXy6PLmuwLvMVZB2RXvgFn4hZMdpwy7CTgFeWWaWHzinx8wzUCcV0LsW9xsrEaT3 nmS57qGNryiVMxLLKI+mZKqnd1WNw9bZWUoiVQg1j0dBWA6aYoWuhwzfS01W9zVm5nsW zEGQ== MIME-Version: 1.0 X-Received: by 10.224.50.84 with SMTP id y20mr1140355qaf.44.1414011420210; Wed, 22 Oct 2014 13:57:00 -0700 (PDT) In-Reply-To: References: Date: Wed, 22 Oct 2014 16:57:00 -0400 Subject: Re: I am out of trial and error again Lists From: Joel Goldstick Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414011422 news.xs4all.nl 2836 [2001:888:2000:d::a6]:58512 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!bete-des-vosges.org!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:79470 On Wed, Oct 22, 2014 at 4:30 PM, Seymore4Head wrote: > def nametonumber(name): > lst=[""] > for x,y in enumerate (name): > lst=lst.append(y) > print (lst) > return (lst) > a=["1-800-getcharter"] > print (nametonumber(a))#18004382427837 > > > The syntax for when to use a () and when to use [] still throws me a > curve. () is tuples which are immutable which means that the items can't be changed. [] is list which means that each item can be changed. Tuples are useful because they can be used as keys in dictionaries and are guarantied not to change. Lists are useful because they can be updated. What you are doing confuses me. You don't use x, which is the enumerated value. FIrst lst should be lst = [] . You don't need to set the first element in the list to an empty string. You just want to establish that you have an empty list called lst Second, you don't need lst = lst.append(y) because you can just say lst.append(y). This will append the y value to the end of the list. As to converting letters to the corresponding numbers on a phone keypad, you don't show you code here for that > > For now, I am trying to end up with a list that has each character in > "a" as a single item. > > I get: > None > None > -- > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com