Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!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.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'causing': 0.04; 'syntax': 0.04; 'subject:help': 0.08; 'python': 0.11; 'wrote': 0.14; "'/'": 0.16; 'delimiters': 0.16; 'formatted': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'line),': 0.16; 'messy': 0.16; 'printing.': 0.16; 'syntaxerror:': 0.16; 'wrote:': 0.18; 'community,': 0.19; 'thu,': 0.19; 'separate': 0.22; 'print': 0.22; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'strongly': 0.30; 'message-id:@mail.gmail.com': 0.30; 'getting': 0.31; 'easier': 0.31; 'lines': 0.31; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'doing': 0.36; 'error.': 0.37; 'two': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'how': 0.40; 'even': 0.60; "you're": 0.61; 'first': 0.61; 'dear': 0.65; 'american': 0.66; 'invalid': 0.68; 'line,': 0.68; "it'd": 0.84; 'nice,': 0.84; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=+CKVcHGJdBDjVww0gCkHmoUzl/lavvmHvMuXpj2UNkQ=; b=KVDduH7qSxm/B84LvN1KYUcFT0FQF7cJbgkWzh+g2MlgnflMJb3yId8S/fnwBaBGlj AfVFmz9/b9AkSVZ8gNqVCtNxdofuHzwE/3TrNXRHCsQ8Z/bTS0h5qYX0zDC2Z4Ebt3HJ CUZCA1tXT3l69yhYLsG0OYdGResb3fpX53NpLPI+XRSBvKwh+nDZc7lbf55vETW0Ggsm EWAvq4Yuw4gUctP3G3VDXk+7VDsOkdQWu2SKND2ZAwBjVMU+pWZ0Q5WUBCqIKMNgmkJF sgv8gszl07vK6kCeJ5j9M/2QCKUtV78f6F9Am28cK/F6thB9zAWDr55I8MbFwSdfl+TO bitw== MIME-Version: 1.0 X-Received: by 10.220.49.1 with SMTP id t1mr2243724vcf.66.1367506743569; Thu, 02 May 2013 07:59:03 -0700 (PDT) In-Reply-To: <1F2E5209-2F0F-4DE2-88BC-DB9C2267B0F3@icloud.com> References: <1F2E5209-2F0F-4DE2-88BC-DB9C2267B0F3@icloud.com> Date: Fri, 3 May 2013 00:59:03 +1000 Subject: Re: help to code... From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1367506746 news.xs4all.nl 15994 [2001:888:2000:d::a6]:43003 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44635 On Thu, May 2, 2013 at 11:50 PM, leonardo selmi wrote: > dear python community, > > i wrote the following program: > > print str(current_month) + '/' + str(current_day) + '/' + str(current_year) > +' '+ > print str(current_hour) + str(current_minute) + str(current_second) > > SyntaxError: invalid syntax > > how can i write the last two lines correctly? You're doing two separate print statements. Either join them into one (if you want it to be one line), or drop the last + on the first line, which is causing your syntax error. But there's an even easier way to do this: Use formatted printing. print("%d/%d/%d %d%d%d"%(current_month,current_day,current_year,current_hour,current_minute,current_second)) Or, since you're getting those straight from 'now': print("%d/%d/%d %d%d%d"%(now.month,now.day,now.year,now.hour,now.minute,now.second)) I strongly suspect that you want to put delimiters in the time, though (colons, perhaps?). It'd be really nice, by the way, if you'd avoid the messy American format date with the month first; put the year first and it's unambiguous! ChrisA