Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!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.030 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'anyway.': 0.05; 'beginner': 0.05; 'trailing': 0.09; 'python': 0.11; "wouldn't": 0.14; 'comma': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'code.': 0.18; 'print': 0.22; 'header:User-Agent:1': 0.23; 'equivalent': 0.26; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'code': 0.31; 'fine,': 0.31; 'obscure': 0.31; "they'll": 0.31; 'received:google.com': 0.35; 'add': 0.35; 'really': 0.36; 'skip:- 20': 0.37; 'to:addr:python- list': 0.38; 'list,': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; 'space': 0.40; 'skip:u 10': 0.60; 'strictly': 0.61; 'advanced': 0.63; 'details': 0.65; 'subject:space': 0.84; 'careful': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=NW4YhFNi9T1hvnLAkH+0qY44Ruj2vE81//m87UkLc8s=; b=FXJGjQWLfnJwInmEtRaJ1TIzQpTOfWgTvaCMX1cEwvv9mtitgVC91BpRqdf6D9ArlG r807csYQAF4C1TnMHnKs3ohaKIim6PJB/knzwaO/e/thtTRCBFl2C2uwqis5UrtD1rtq 9iHLizeUmJmKedpV71uyt0fh6uyiDsaN4SiAARLftK6dzNHq1Chbt2kbqNDnnBuBW1gq Myvl5avbBsvV00LN+kPrvRq0XkL23+///P2AutjK2DoNIoB30EzJXDwUtSrgbRNXZ+Jg ELorNblkAt3HmXoUMP/EyTBvLMq+p8tGRkWniNB0y2otC5NyA/lT+QnvnH76OJUBl7Z3 RY4w== X-Received: by 10.49.6.99 with SMTP id z3mr16855450qez.27.1377948295410; Sat, 31 Aug 2013 04:24:55 -0700 (PDT) Sender: Ned Batchelder Date: Sat, 31 Aug 2013 07:24:54 -0400 From: Ned Batchelder User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: python-list@python.org Subject: Re: print function and unwanted trailing space References: <5221a693$0$2059$426a74cc@news.free.fr> In-Reply-To: <5221a693$0$2059$426a74cc@news.free.fr> 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1377948297 news.xs4all.nl 16007 [2001:888:2000:d::a6]:37127 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53343 On 8/31/13 4:17 AM, candide wrote: > > What is the equivalent in Python 3 to the following Python 2 code: > > # ----------------------------- > for i in range(5): > print i, > # ----------------------------- > > ? > > Be careful that the above code doesn't add a trailing space after the > last number in the list, hence the following Python 3 code isn't > strictly equivalent: > > > # ----------------------------- > for i in range(5): > print(i, end=' ') # <- The last ' ' is unwanted > print() > # ----------------------------- For a beginner course, the trailing space is fine, use this code. They'll never notice the trailing space (I wouldn't have!) and to explain why the comma leaves off the last one takes a really advanced understanding of obscure details anyway. --Ned.