Howdy, Stranger!

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

Supported by

[solved] Why am I getting repeats?

edited July 2014 in OpenSesame

Ok this is driving me mad, I have commented most of it out to try and eliminate mistakes but my final list always gets some repeats and some omissions. Desperate for an answer.

import random


picList = ["achievement.jpg", "admired.jpg", "alert.jpg", "cope.jpg", "energy.jpg", 
"friendships.jpg","good_decision.jpg", "good_news.jpg", "good_times.jpg", "healthy.jpg", 
"hope.jpg", "liked.jpg", "praised.jpg", "problem_solve.jpg", "success.jpg"]



random.shuffle(picList)


cue = picList


pic= cue[0] 


exp.set("pic", pic)

Comments

  • edited 4:45PM

    Hi,

    The short answer could be a bit frustrating, but is very clear: You should not be having any repeats in the picList after shuffling it. There could be repeats, however, if there is more processing being done on the list later on!

    Another possibility is that you have defined a custom random library, where the shuffle function does produce repeats (but this is something you would probably know, and is quite unlikely).

    Best,

    Edwin

  • edited 4:45PM

    Closing as duplicate of #1064.

    @ghostrider Please don't post the same question multiple times!

This discussion has been closed.