Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'referring': 0.07; 'received:67.192': 0.09; 'received:67.192.241': 0.09; 'received:dfw.emailsrvr.com': 0.09; 'type,': 0.09; 'random': 0.14; '(am': 0.16; 'cherry': 0.16; 'code?': 0.16; 'comma': 0.16; 'email addr:comcast.net': 0.16; 'wrote:': 0.18; 'typing': 0.19; 'import': 0.22; 'header:User-Agent:1': 0.23; 'received:emailsrvr.com': 0.24; 'received:(smtp server)': 0.26; 'this:': 0.26; 'header:In-Reply- To:1': 0.27; 'words': 0.29; 'easier': 0.31; 'gary': 0.31; 'reader': 0.33; 'there': 0.35; 'method': 0.36; 'list': 0.37; 'thank': 0.38; 'apple': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'how': 0.40; 'you.': 0.62; 'save': 0.62; 'between': 0.67; 'characters,': 0.84; 'clearer': 0.84; 'pie': 0.84 X-Virus-Scanned: OK Date: Tue, 13 Aug 2013 22:12:56 -0700 From: Gary Herron User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130803 Thunderbird/17.0.8 MIME-Version: 1.0 To: python-list@python.org Subject: Re: .split() Qeustion References: <94f8428f-50b9-4ccd-95a0-6eeafda0fe18@googlegroups.com> In-Reply-To: <94f8428f-50b9-4ccd-95a0-6eeafda0fe18@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1376457700 news.xs4all.nl 15901 [2001:888:2000:d::a6]:53685 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52492 On 08/13/2013 09:51 PM, eschneider92@comcast.net wrote: > How can I use the '.split()' method (am I right in calling it a method?) without instead of writing each comma between words in the pie list in the following code? Also, is there a way to use .split instead of typing the apostrophes? Thank you. > > import random > pie=['keylime', 'peach', 'apple', 'cherry', 'pecan'] > print(random.choice(pie)) > > Eric I think you are referring to this: pie = 'keylime peach apple cherry pecan'.split() While it's easier to type, and does save a few characters, I think the original list is clearer to a reader of your program. Gary Herron