Python Forum

Full Version: print
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Trying this
from PIL import Image
import os, os.path

imgs = []
path = "c/users/anybloodyid/pictures/"
valid_images = [".jpg",".gif",".png",".tga"]
for f in os.listdir(path):
    ext = os.path.splitext(f)[1]
    if ext.lower() not in valid_images:
        continue
    imgs.append(Image.open(os.path.join(path,f))
	print (imgs)
keep getting this
    print (imgs)
        ^
SyntaxError: invalid syntax
All I want to do is place some png images in an array so I can then later pick them at random
Any help welcome.
You're missing a closing parenthesis on the previous line.
Thanks for that, should have spotted it, open 3, close 3