You did it right, not sure why it doesn't work for you.
From the manual:
Generate a random float from 0 to x, not including x. E.g. random(4) can generate 0, 2.5, 3.29293, but not 4. Use floor(random(4)) to generate just the whole numbers 0, 1, 2, 3.
Generate a random float between a and b, including a but not including b.