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!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; 'else:': 0.03; 'bits': 0.09; 'input,': 0.09; '-tkc': 0.16; 'answers:': 0.16; 'entries.': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'subject:break': 0.16; 'subject:possible': 0.16; 'throw': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'split': 0.19; 'input': 0.22; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'run': 0.32; 'skip:d 20': 0.34; 'could': 0.34; 'something': 0.35; 'like,': 0.36; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'easily': 0.37; 'question,': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'ensure': 0.60; 'read': 0.60; 'numbers': 0.61; 'email addr:gmail.com': 0.63; 'more': 0.64; 'extras': 0.84; 'received:50.22': 0.84 Date: Wed, 4 Dec 2013 09:55:43 -0600 From: Tim Chase To: python-list@python.org Subject: Re: Input without line break, is it possible? In-Reply-To: <6f831d02-26bf-4e68-a1c6-a9c9e87db1dc@googlegroups.com> References: <6f831d02-26bf-4e68-a1c6-a9c9e87db1dc@googlegroups.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Get-Message-Sender-Via: boston.accountservergroup.com: authenticated_id: tim@thechases.com 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: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1386172467 news.xs4all.nl 2904 [2001:888:2000:d::a6]:34498 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61029 On 2013-12-04 07:38, geezle86@gmail.com wrote: > for i in range(8): > n = input() > > When we run it, consider the numbers below is the user input, > > 1 > 2 > 3 > 4 > 5 > 6 > (and so forth) > > my question, can i make it in just a single line like, > > 1 2 3 4 5 6 (and so forth) Not easily while processing the input one at a time. You can, however, read one line of input and then split it: s = input() bits = s.split() if len(bits) != 8: what_now("?") else: for bit in bits: do_something(bit) You could make it a bit more robust with something like: answers = [] while len(answers) < 8: s = input() answers.append(s.split()) del answers[8:] # we only want 8, so throw away extras for answer in answers: do_something(answer) which would at least ensure that you have 8 entries. -tkc