# ReferenceError: num\_items is not defined

**URL:** <https://discourse.psychopy.org/t/referenceerror-num-items-is-not-defined/7510>\
**Category:** Online experiments\
**Created:** [April 23, 2019, 9:57pm UTC](https://discourse.psychopy.org/t/referenceerror-num-items-is-not-defined/7510 "2019-04-23T21:57:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roman\_Slobodianiuk](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/roman_slobodianiuk/32/4538_2.png) [@Roman\_Slobodianiuk](https://discourse.psychopy.org/u/Roman_Slobodianiuk)\
**Post date:** [April 23, 2019, 9:57pm UTC](https://discourse.psychopy.org/t/referenceerror-num-items-is-not-defined/7510/1 "2019-04-23T21:57:26Z")

</div>

URL of experiment:  
[https://pavlovia.org/run/Ramzes215/compos\_arch/html/](https://pavlovia.org/run/Ramzes215/compos_arch/html/)  
Description of the problem:  
Hello, after uploading an experiment to Pavlovia I have got ReferenceError: num\_items is not defined.

As I understand from other topics, the problem is that I only wrote a Pyton code.

Begin Experiment part

> import random, xlrd
> 
> random.seed()
> 
> in\_file = “stimuli\_1.xlsx”
> 
> num\_items = 10
> 
> cur\_image1 = 0  
> cur\_image2 = 0  
> cur\_image3 = 0

 ![50](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/1/3/13585b9f66b17a08f7e551db1f35248d382e6834.png)

Begin Routine part

> inbook = xlrd.open\_workbook(in\_file)  
> insheet = inbook.sheet\_by\_index(0)
> 
> image1\_stim =   
> image2\_stim =   
> image3\_stim =
> 
> for rowx in range (1, num\_items + 1):
> 
> ```
> row = insheet.row_values(rowx)
> 
> image1_stim.append(row[0])
> image2_stim.append(row[1])
> image3_stim.append(row[2])
> 
> ```
> 
> random.shuffle(image1\_stim)  
> random.shuffle(image2\_stim)  
> random.shuffle(image3\_stim)

 ![40](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/0/9/09127fd281a1df5e0422a90ce72c6fb449f7492b.jpeg)  
End Routine part

> thisExp.addData(“image1\_stim”, image1\_stim[cur\_image1])  
> thisExp.addData(“image2\_stim”, image2\_stim[cur\_image2])  
> thisExp.addData(“image3\_stim”, image3\_stim[cur\_image3])
> 
> cur\_image1 = cur\_image1 + 1  
> cur\_image2 = cur\_image2 + 1  
> cur\_image3 = cur\_image3 + 1

And if I want to run this experiment online I need to write  
a similar code in Java?  
Thank you, Roman.

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [April 23, 2019, 10:07pm UTC](https://discourse.psychopy.org/t/referenceerror-num-items-is-not-defined/7510/2 "2019-04-23T22:07:36Z")

</div>

> [@Roman\_Slobodianiuk](#):
>
> And if I want to run this experiment online I need to write  
> a similar code in Java?

- Yes, but the language you need is JavaScript, not Java (one of the most confusing naming decisions in the history of programming…))
- Just select “both” as the code type in your code component so you can see the original Python code to translate into JavaScript in the other pane.
