Python Forum
print - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: print (/thread-14366.html)



print - Graham - Nov-26-2018

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.


RE: print - stranac - Nov-26-2018

You're missing a closing parenthesis on the previous line.


RE: print - Graham - Nov-26-2018

Thanks for that, should have spotted it, open 3, close 3