# \[Easy\] Python array append

**URL:** <https://forum.inductiveautomation.com/t/easy-python-array-append/6939>\
**Category:** Ignition\
**Created:** [July 26, 2013, 2:32pm UTC](https://forum.inductiveautomation.com/t/easy-python-array-append/6939 "2013-07-26T14:32:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![randomranger](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@randomranger](https://forum.inductiveautomation.com/u/randomranger)\
**Post date:** [July 26, 2013, 2:32pm UTC](https://forum.inductiveautomation.com/t/easy-python-array-append/6939/1 "2013-07-26T14:32:13Z")

</div>

I have set up a simple array designed to take in file paths from the system.file.getTempFile() method which returns a string. However, when I attempt to run my script I will get an error that says “IndexError: index out of range: 1” and the error will point to the line printing out the array value (last line of code). I believe this is due to there not being anything with a value, or anything at all in the location of the array it’s being asked to print. Here is my whole script.

`CompanyGridData = event.source.parent.getComponent("companyDisplay").data
counter = 0
for counter in range(0, CompanyGridData.getRowCount()): #CompanyGridData.getRowCount() returns 3 and works fine
	tempFile = []
	tempFile.append(system.file.getTempFile(".jpg"))
	print tempFile[counter]`  
If you want a look at the actual error report, heres a link:  
[http://pastebin.com/W6yCZGEA](http://pastebin.com/W6yCZGEA)

If anyone has any ideas as to why this is happening, please let me know.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 26, 2013, 2:39pm UTC](https://forum.inductiveautomation.com/t/easy-python-array-append/6939/2 "2013-07-26T14:39:35Z")

</div>

Move your declaration of the tempFile outside the loop. Also, just to clarify, you’re dealing with a list here, not an array.

---

<div class="post-metadata">

**Author:** ![randomranger](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@randomranger](https://forum.inductiveautomation.com/u/randomranger)\
**Post date:** [July 26, 2013, 2:42pm UTC](https://forum.inductiveautomation.com/t/easy-python-array-append/6939/3 "2013-07-26T14:42:08Z")

</div>

Thanks Kevin, looks so obvious now.
