I need a line with different random numbers that have been picked once

I’m trying to solve an exercise, that i have to do a line, with for cycle. I need that it looks like this

6
8
9
3
1

but the only thing that I have is multiple numbers, in the same place, multiple times. I don’t know how to pick different random numbers every time the cycle for runs only once, and not every time the void draw read the code. I understand that the random function it’s inside the void draw, but, if I put it into the void setup, it only choose all the times the same number, like this:

2
2
2
2
2

the code that I am using, is this, hope someone can help me and fix it :heart:

int tam = 25;
int valAnterior;

void setup(){
size(600,400);
textSize(tam);

}

void draw(){
background(200);
for(int i=1; i<6; i++){
text(valAnterior, width/5, i*tam);
valAnterior = round(random(0,9));
}

}

Not gonna lie it looks like you’ve just posted an assignment in the hope that someone solves it for you

Hello,

Look up each function you are using (and the related ones) and a solution will be forthcoming.

One of the best tools in a programmer’s tool chest is knowing the resources available to you and learning to navigate, filter, and use them.

A short list of resources to peruse:

Resources < Click here to expand !

Explore the resources available here:

:)