# Problem with programming a randomized experiment

**URL:** <https://discourse.psychopy.org/t/problem-with-programming-a-randomized-experiment/42894>\
**Category:** Builder\
**Created:** [November 11, 2024, 9:18am UTC](https://discourse.psychopy.org/t/problem-with-programming-a-randomized-experiment/42894 "2024-11-11T09:18:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![n.erdm](https://avatars.discourse-cdn.com/v4/letter/n/13edae/32.png) [@n.erdm](https://discourse.psychopy.org/u/n.erdm)\
**Post date:** [November 11, 2024, 9:18am UTC](https://discourse.psychopy.org/t/problem-with-programming-a-randomized-experiment/42894/1 "2024-11-11T09:18:14Z")

</div>

Hi, I am trying to create an experiment with randomized trials. It will be a translation experiment so I have 50 word pairs. The problem is that I want to create a mixed block in which 25 words from language 1 should appear and 25 words from language two. It should be randomized which words appear from the word pairs in which language, but if a word is presented in one language then the counterpart in language 2 should not appear in the block. How do I do that and how does it work that exactly 25 words appear in every language from the 50 word pair excel list? Do I have to program this directly in Psychopy or use excel and randomize manually for every participant?  
Thank you!

---

<div class="post-metadata">

**Author:** ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)\
**Post date:** [November 11, 2024, 9:43am UTC](https://discourse.psychopy.org/t/problem-with-programming-a-randomized-experiment/42894/2 "2024-11-11T09:43:05Z")

</div>

I would have one spreadsheet with 50 rows and a column for each language and have a shuffled list of 25 1s and 25 2s. Then I could use a code component with something like:

```auto
if shuffledList[trials.theN] == 1:
     thisWord = lang1
else:
     thisWord = lang2

```
