Separate your problem into micro-problems, as @Woss commented. What you need to solve this problem?
- Create an empty list
- Request 20 times for the user to enter the numbers. What is the best way to do this?;
- Every new number the user enters, put it in the list. Use
append
;
- After the 20 iterations of the Voce user you will have your complete list;
- Scroll through your newly created list, item by item. What’s the best way to do this?
- As you go through your list, make conditions to change your values, as stated. (Here you can create a second list to save the new result or change the existing list);
- Print the list with the new results to see.
----------------- or ------------------
- Create an empty list
- Request 20 times for the user to enter the numbers;
- At each new number the user enters, make the necessary conditions to already record the typed number replaced by the statement logic;
- Print the list with the new results to see.
In this second example, exactly what was stated was not done, for example. Because according to "ask the user for numbers and store them in a 20 position vector", it implies that Oce needs to create a list of the numbers typed by the user before converting them.
That’s more or less what you need to do. Of course each programmer can think of a different logic. Try to be part of it. And keep on researching what you can’t do little by little... Dividing a problem into several helps you better understand the logic you need to use..
Separate problems into two questions and detail as much as you can. You could explain exactly what you did in your code?
– Woss
Leonardo, you need to try to make the problem and when a doubt arises you search here on the site, because it is almost certain that someone already had your doubt. If you still don’t find an answer, then you open a question with your question. What part of the problem do you not understand?
– fernandosavio
I did an input for the user to enter the values, and after that I tried to get all numbers smaller or equal to 0 of the vector to be exchanged for 0, and the same thing for the ones below. But when running after entering the numbers the process is finished and the value substitution part does not work.
– Leonardo Martins
You are reassigning the variable
numeros
every time; first reading the 20 numbers; second filtering the list of less than or equal to zero, replacing the value with 0 (i.e., it will be a list of zeroes only); third is replacing all values less than 10 by 1, but since the list is zeros integer all will be replaced by one; room is replacing values greater than or equal to 10 by 2, but since they are all 1 the result will be an empty list. Do the table test to better understand.– Woss