Ask Your Question
1

Input row by row

asked 2020-12-29 22:11:39 +0100

Cyrille gravatar image

updated 2020-12-29 22:11:53 +0100

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 ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-12-29 23:19:06 +0100

slelievre gravatar image

One 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']
edit flag offensive delete link more

Comments

Slelievre 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.

Cyrille gravatar imageCyrille ( 2020-12-30 10:34:14 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-12-29 22:11:39 +0100

Seen: 155 times

Last updated: Dec 29 '20