Skip to content
Advertisement

limited input numbers and save a list into a list

JavaScript

user input example

JavaScript

split using ” ” the space between them and turn them to inteager the and should be =

JavaScript

but after spliting and converting each number should be < 10 and >= 0

and save it to be the

JavaScript

i need to input the line 9 times not once and been duplicate

Advertisement

Answer

Here’s the code updated for your current question.

JavaScript

When I enter the numbers 1 through 9 nine times, it outputs the following,

JavaScript

If I enter a negative number or a number with more than 1 digit, s will be the wrong length, or l will not contain enough numbers. Each of your inputs are checked properly and out becomes a list of 9 lists containing nine integers. Now it prompts for that original input 9 times, providing a list of 9 separate lists with numbers chosen by the user.

Advertisement