Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #65572
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'string.': 0.05; 'subject:Python': 0.06; 'result,': 0.07; 'variables': 0.07; 'subject:help': 0.08; 'string': 0.09; 'cc:addr:python-list': 0.11; 'assume': 0.14; 'between.': 0.16; 'concatenate': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'integer.': 0.16; 'seconds,': 0.16; 'seconds.': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'variable': 0.18; '(the': 0.22; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'format,': 0.24; 'integer': 0.24; 'string,': 0.24; 'cc:2**0': 0.24; 'second': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; 'this.': 0.32; 'url:python': 0.33; 'fri,': 0.33; 'third': 0.33; 'could': 0.34; 'subject:with': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'minutes,': 0.36; 'doing': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'seconds': 0.37; 'turn': 0.37; 'two': 0.37; 'url:library': 0.38; 'pm,': 0.38; 'how': 0.40; 'easy': 0.60; "you're": 0.61; 'first': 0.61; 'minutes': 0.67; 'to:none': 0.92; 'scott': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=8+YYr/M/bSnZ1wnhR9n4yjC/Agz8lNjHTvui9N9OZ9I=; b=0cHwvbKhJBfPAkOAkp4864H1RFGPUreMrfvGtMZBcmGcxzmbjjSdElDURiSzp0rnoX PzrzGKA2yCHmV5vj0SE7hZOHedm3mhrXkmwAKx2xiWKxy4g7UMdadORVMjmom1ejPKUu wl1iMAtUB++Inz/1iUdVatJcM6gZE3mnwkaa7IjNbpSiNgbMAyjMmdAMjU5djCRbivMF 7/fi9zXndwTAPXHCc34NureKQ8EkAtI76KYK0cW9JJMGlPePyI9//coZZHC81njWbrOk dwBrRBH3V9uOWBYREmHNqWGs9AE+dajmPi62OQYwY3jsLGWJUGwuNLPUR1IAjagrRy/a gtmA== |
| MIME-Version | 1.0 |
| X-Received | by 10.68.247.6 with SMTP id ya6mr16023386pbc.45.1391737066728; Thu, 06 Feb 2014 17:37:46 -0800 (PST) |
| In-Reply-To | <DC365E9C-9511-49BD-A53F-67B4ED3A561F@cox.net> |
| References | <DC365E9C-9511-49BD-A53F-67B4ED3A561F@cox.net> |
| Date | Fri, 7 Feb 2014 12:37:46 +1100 |
| Subject | Re: Python 2.7.6 help with white spaces? |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| 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 | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.6468.1391737069.18130.python-list@python.org> (permalink) |
| Lines | 36 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1391737069 news.xs4all.nl 2854 [2001:888:2000:d::a6]:37755 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:65572 |
Show key headers only | View raw
On Fri, Feb 7, 2014 at 12:22 PM, Scott W Dunning <swdunning@cox.net> wrote: > Assume variables exist for minutes and seconds. Each variable is an integer. > How would you create a string in the format, > > 3:11 > > with no spaces. where 3 is minutes and 11 is seconds. > > > Obviously when I⦠> > print minutes, ā:ā, seconds > > I get 3 : 11 > > how can I get it to print with no spaces? > > 3:11 The print statement isn't right for what you're doing here. You need to create a single string with that result, which you could then print out. There are two easy ways to do this. First one is to create a string from the number of minutes, create a string from the number of seconds, and concatenate them, with a third string (the colon) in between. Do you know how to turn an integer into a string, and do you know how to add strings together? The second way is to format the values directly into a single string. You can use printf codes for this. Check this out: http://docs.python.org/2/library/stdtypes.html#string-formatting-operations ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Python 2.7.6 help with white spaces? Chris Angelico <rosuav@gmail.com> - 2014-02-07 12:37 +1100
csiph-web