Out of bounds get Index

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By givenmnisi6

It runs then closes

This is my code:

ctrl1.get_node(“Question”).bbcode_text = “[center]” + questions.keys()[chosen] + “[/center]”

I assume questions is a Dictionary? What keys does it contain? What’s the value of chosen at the time of the error?

Normally, I’d expect some sort of Invalid get index ‘x’ error on a Dictionary rather than an out of bound error…

— Edit —

Ah, right, the result of keys() IS an array - hence the array oriented error…

jgodfrey | 2023-07-13 18:41

here is my dictionary array.

I declared it as
var questions: Dictionary #To Store the Questions


givenmnisi6 | 2023-07-13 21:36

:bust_in_silhouette: Reply From: Enfyna

You can use this for an easy fix. Basically let say we have this : arr = ["apple","banana"] then arr[1] would be equal to “banana” and if you tried to do arr[2] you get a error like that.

I still get the same error

givenmnisi6 | 2023-07-13 21:47