I have a program that needs to sort through 10 .ppm files and average the the three colors (red,green,blue) per line and return them in a file back to create the final image. Right now, it's giving me an error at line 11 after the start of the first for loop saying index error list assignment index out of range. The image files are stored in the PPM format. The structure of the text file is as follows: The first line contains the string P3. The second line contains two integers which give the width and height of the image in pixels. We'll call these w and h. The third line contains a single integer that tells the maximum value used for a color value for red, blue, and green components of each pixel. For this assignment the maximum value will always be 255. The remainder of the file consists of w × h lines. Each of these lines contains three integers representing the red, blue, and green component of a single pixel. This is what I have so far and any help would be great. Thanks!
def imageStacker():
userInput = input('What is the name of the image set you would like to process?: ')
#fileName = str(userInput) + '_'
print(type(userInput))
fileRef = []
content = []
for i in range(10):
fileRef[i] = open(userInput + '_' + str(i +1) + '.ppm', 'r')
for i in range(10):
content[i] = fileRef[i].readlines()
print(list(content))