Input without line break, is it possible?

Mark Lawrence breamoreboy at yahoo.co.uk
Wed Dec 4 17:27:46 CET 2013


On 04/12/2013 16:14, Chris Angelico wrote:
> On Thu, Dec 5, 2013 at 3:04 AM, Mark Lawrence <breamoreboy at yahoo.co.uk> wrote:
>> On 04/12/2013 15:38, geezle86 at gmail.com wrote:
>>>
>>> The source code:
>>>
>>> for i in range(8):
>>>      n = input()
>>
>> Yes you can get them on a single line, see the response from Tim Chase.  But
>> just to be crystal clear, are you aware that you're getting string
>> representations of numbers, and not the numbers themselves?
>
> Just to clarify, this is assuming that you're using Python 3. Geezle,
> if you're using Python 2, you need to not use input() for anything -
> use raw_input() instead, which will do what we're describing here.

Good point, I saw input() and automatically assumed Python 3, what a 
sin!  The assumption obviously, not Python 3!!

>
> I yearn for the day when nobody uses Python 2 any more so this doesn't
> need to be asked.
>

I'm contemplating what it would be like migrating code from Python 1.x 
to Python 4.0, the fun and games that could be :)

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list