image - Save list in Python -


i want save list of strings in python array. code below:

import os images_list=[os.listdir("/home/metal-machine/pictures/new")] print images_list[0] 

it prints list in [0] , when use

print images_list[1] 

it returns error as: indexerror: list index out of range

i sure "index out of range" because elements of list not separated comma.

for can use split() method in python.

images_list.split() 

and above command splits files putting commas in-between of them, why python by-default not put commas in between elements? sunch kind of list valid in python?

why not write code bit more error free

for images in images_list:     print images 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -