I've been trying to figure this out for a while now.
So I have a list containing 1,2,3,4,5,6,7,8,9,10 and I have a function that randomly selects an item on the list as well as the item 1 index below and above it.
For example, if it randomly picks 6, then the output list would be 5,6,7.
But I'm having trouble when it selects 1 or 10 since then it would output " ", 1, 2 and the like.
I want to delete the list that has a blank in it and basically repeat the random item selection function until I get a list that doesn't have a blank (if that makes sense?)
This is a strange question. If you want a random number between 2 and 9, why use a list? Why not just ? (2 to 9 because that solves the problem of the missing neighbor.)
Are you trying to retrofit a list into your program for the sake of the AP CSP Create Task?
try this:
*
Example
if you don't want to create a new block, you can just do this instead
The reason this works is because when you use the value variable, it doesn't place the item in blank spots.
or even just
lol, never thought of that.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.