Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41600

Re: join()

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'removes': 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; 'subject:()': 0.09; '"write': 0.16; "'is',": 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sunny': 0.16; 'wrote:': 0.17; 'string,': 0.17; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'raw': 0.27; 'header:X -Complaints-To:1': 0.28; '>>>>': 0.29; 'whitespace': 0.29; 'words': 0.29; "i'm": 0.29; "skip:' 10": 0.30; 'code': 0.31; 'from:addr:yahoo.co.uk': 0.32; 'to:addr:python-list': 0.33; 'thanks': 0.34; 'doing': 0.35; 'received:org': 0.36; 'but': 0.36; 'subject:: ': 0.38; 'mark': 0.38; 'to:addr:python.org': 0.39; 'space': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'between': 0.63; 'today': 0.67; 'weather': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: join()
Date Wed, 20 Mar 2013 14:44:32 +0000
References <6110d82b-fce9-4146-8fcc-3276334a8f5f@14g2000vbr.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-92-18-20-125.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.0; rv:17.0) Gecko/20130307 Thunderbird/17.0.4
In-Reply-To <6110d82b-fce9-4146-8fcc-3276334a8f5f@14g2000vbr.googlegroups.com>
X-Antivirus avast! (VPS 130311-2, 11/03/2013), Outbound message
X-Antivirus-Status Clean
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3566.1363790630.2939.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1363790630 news.xs4all.nl 6900 [2001:888:2000:d::a6]:37159
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:41600

Show key headers only | View raw


On 20/03/2013 14:05, franzferdinand wrote:
> I'm doing this "Write code that removes whitespace at the beginning
> and end of a string, and normalizes whitespace between words to be a
> single space character"
>
> I can do it using split()
>
>>>> raw = "      the     weather is     sunny                  today       "
>>>> raw.split()
> ['the', 'weather', 'is', 'sunny', 'today']
>
> But how do I do it using join() ?? Thanks
>

' '.join(raw.split())

-- 
Cheers.

Mark Lawrence

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

join() franzferdinand <melo.dumoulin@hotmail.com> - 2013-03-20 07:05 -0700
  Re: join() Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2013-03-20 14:34 +0000
  Re: join() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-20 14:39 +0000
    Re: join() Tim Chase <python.list@tim.thechases.com> - 2013-03-20 10:54 -0500
      Re: join() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-20 18:44 +0000
  Re: join() Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-03-20 14:44 +0000
    Re: join() franzferdinand <melo.dumoulin@hotmail.com> - 2013-03-20 07:46 -0700

csiph-web