ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 30 Dec 2020 10:34:14 +0100Input row by rowhttps://ask.sagemath.org/question/54997/input-row-by-row/ A question which has perhaps no answer. This command do exactly what I expect
M=[input(r'ABCD : '),input('BCDA: '),input('BCAD: ')]
**but** I have potentially a huge list to input and as the inputs are asked sequentially this will take ahuge number of rows in in my screen.
So is there a mechanism which permit to select multi-columns in each rows ?Tue, 29 Dec 2020 22:11:39 +0100https://ask.sagemath.org/question/54997/input-row-by-row/Answer by slelievre for <p>A question which has perhaps no answer. This command do exactly what I expect</p>
<pre><code>M=[input(r'ABCD : '),input('BCDA: '),input('BCAD: ')]
</code></pre>
<p><strong>but</strong> I have potentially a huge list to input and as the inputs are asked sequentially this will take ahuge number of rows in in my screen.</p>
<p>So is there a mechanism which permit to select multi-columns in each rows ?</p>
https://ask.sagemath.org/question/54997/input-row-by-row/?answer=54999#post-id-54999One solution would be to use a single `input` for a number of entries.
The user would enter inputs separated by spaces.
Then you would split the resulting string according to spaces.
Something like:
sage: s = 'ABCD BCDA BCAD DACB: '
sage: M = input(s).split()
ABCD BCDA BCAD DACB: 7 8 0 3
sage: M
['7', '8', '0', '3']
Tue, 29 Dec 2020 23:19:06 +0100https://ask.sagemath.org/question/54997/input-row-by-row/?answer=54999#post-id-54999Comment by Cyrille for <p>One solution would be to use a single <code>input</code> for a number of entries.</p>
<p>The user would enter inputs separated by spaces.</p>
<p>Then you would split the resulting string according to spaces.</p>
<p>Something like:</p>
<pre><code>sage: s = 'ABCD BCDA BCAD DACB: '
sage: M = input(s).split()
ABCD BCDA BCAD DACB: 7 8 0 3
sage: M
['7', '8', '0', '3']
</code></pre>
https://ask.sagemath.org/question/54997/input-row-by-row/?comment=55007#post-id-55007Slelievre as you certainly have already seen I have found a way to input datas minimizing the error from the user. Your solution could be fine if there was a way to be sure that if I ask for 4 number the user did not enter 5 which is there possible. I will come back soon perhaps with a good solution.Wed, 30 Dec 2020 10:34:14 +0100https://ask.sagemath.org/question/54997/input-row-by-row/?comment=55007#post-id-55007