Apr-16-2022, 03:12 PM
Hi simple help needed please. Just trying to print a specific item in the list. If I iterate through the list I can print each value on a new line. If I try to specify a value in the list it prints a character from the last value in the list. This makes me doubt that I am even working with a 'list' at all. How do I address a specific value in this 'list'? And actually I just run Type command it looks like it is in fact a 'class 'list'
my_list = ['-rw-rw-r--', '1', 'root', 'root', '652173', 'Apr', '21', '2020', 'ecs_12032020.cfg'] print (my_list) print ("------------------------") for x in my_list: print (x) print ("------------------------") print (x[7])OUTPUT:
Output:['-rw-rw-r--', '1', 'root', 'root', '652173', 'Apr', '21', '2020', 'ecs_12032020.cfg']
------------------------
-rw-rw-r--
1
root
root
652173
Apr
21
2020
ecs_12032020.cfg
------------------------
3
Many Thanks.