Ask Your Question
1

Input row by row

asked 4 years ago

Cyrille gravatar image

updated 4 years ago

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 ?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 4 years ago

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']
Preview: (hide)
link

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 ( 4 years ago )

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: 4 years ago

Seen: 192 times

Last updated: Dec 29 '20