Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bcyclone02.am1.xlned.com!bcyclone02.am1.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: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:error': 0.03; 'from:addr:yahoo.co.uk': 0.04; 'syntax': 0.04; '22,': 0.09; 'immutable': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'throws': 0.09; 'wrong,': 0.09; 'def': 0.12; 'language.': 0.14; 'curve.': 0.16; 'dictionaries': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'language': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'print': 0.22; 'header:User-Agent:1': 0.23; 'define': 0.26; 'header:X-Complaints- To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'changed.': 0.31; 'keys': 0.31; 'tuples': 0.31; 'lists': 0.32; 'skip:c 30': 0.32; "can't": 0.35; 'useful': 0.36; 'list': 0.37; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:n 10': 0.64; 'our': 0.64; 'charset:windows-1252': 0.65; 'received:89': 0.85; 'joel': 0.91; 'subject:Lists': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: I am out of trial and error again Lists Date: Wed, 22 Oct 2014 22:28:04 +0100 References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-89-240-167-43.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414013297 news.xs4all.nl 2966 [2001:888:2000:d::a6]:36814 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 3910 X-Received-Body-CRC: 3831051757 Xref: csiph.com comp.lang.python:79472 On 22/10/2014 21:57, Joel Goldstick wrote: > 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. > This is wrong, commas define tuples. type mytest.py a = 1, 2 print(type(a)) c:\Users\Mark\MyPython>mytest.py -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence