Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] how to randomly vary the length of a cycle of words

edited March 2013 in OpenSesame

Hi,

I'm relatively new to Open Sesame and so far, I haven't had any problems that couldn't be solved with the available documentation. However, now I am stuck with a seemingly easy part of my task:

I need to present a cycle of words (200 ms each), that randomly varies between 40 and 60 words. I've created a loop with the variable 'words'. Then I've imported the module 'random' and tried to use random.randint () to limit the duration of the loop, but this doesn't seem to work.

Is there another way to accomplish this? Many thanks in advance!

Stefan

Comments

  • edited March 2013

    Hi Stefan.

    Imagine that your loop name is words_loop. By inserting this code:

    import random
    rep = random.randint(40,60)
    exp.items['words_loop'].repeat = rep
    

    before the loop item, the loop will last according to the number of repetitions indicated by the rep variable. So, you have no need to define a words variable inside the loop.

    Hope this helps.

    Cheers,

    Andrea

  • edited 1:54PM

    That definitily helped! Thanks a lot.

    Stefan

Sign In or Register to comment.