Topic was automatically imported from the old Question2Answer platform.
Asked By
golden_pangolin
I’m have trouble trying to convert a returned dictionary value into code.
My dictionary value returns as "(randi() % 11 + 2)" which is a string. Is there a simple way to convert this into code? Do I have to use a regexp to remove the quotations?
I’ve tried int() and it didn’t work to generate a random number in the range listed above.
You can use the call() or callv functions but first your dictionary value is in bad format. You can either slice your string or rearrange it in a way to be compatible with those functions
# this assumes no encapsulation of ( )
var callv("randi() % 11 + 2".split("()")