Set variable as random letter between A and Z


#1

Right now, in CoBlocks, I can for example set a variable to be a random integer between 1 and 100.

image

Is it possible to do the same, but now instead a random letter between A and Z?


#2

Hi @sj187,

right now we don’t have such a block unfortunately. What would you like to use it for?


#3

For a puzzle.

Thanks for letting me know; I have simply instead used the If operator to execute this, though it adds many lines of code.


#4

Couldn’t you just set the the code to pick a random integer from 0 to 26?


#5

Yes but then there is still the problem of producing the letters.


#6

Create an array, each item as a letter. Then pick item [random number 0-25] from the array.


#7

How do I do that in CoBlocks?


#8

image


#9

Thanks for the suggestion.

But that is not significantly simpler than what I actually did.