Python Forum
Printing through list.. again
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Printing through list.. again
#1
Question 
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.
Reply


Messages In This Thread
Printing through list.. again - by jesse68 - Apr-16-2022, 03:12 PM
RE: Printing through list.. again - by menator01 - Apr-16-2022, 03:16 PM
RE: Printing through list.. again - by jesse68 - Apr-16-2022, 03:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  help for list printing jip31 8 5,088 May-01-2021, 03:52 AM
Last Post: Pedroski55
  Problem printing last element from a list tester_V 3 3,879 Oct-30-2020, 04:54 AM
Last Post: tester_V
  Printing empty list? hhydration 2 2,784 Oct-28-2020, 11:34 AM
Last Post: Atekka
  Printing images from a list Heyjoe 4 3,936 Jun-22-2020, 02:28 AM
Last Post: Heyjoe
  printing a list contents without brackets in a print statement paracelx 1 2,849 Feb-15-2020, 02:15 AM
Last Post: Larz60+
  Printing List in one line bharat_s579 6 5,313 May-26-2019, 08:30 PM
Last Post: perfringo
  list is printing incorrectly.. anna 1 2,617 May-18-2019, 12:12 PM
Last Post: ichabod801
  Printing one thing from a list bidoofis 1 2,954 Feb-05-2019, 09:02 PM
Last Post: ichabod801
  Printing a new python list abdallah786 3 124,418 Aug-17-2018, 03:21 PM
Last Post: buran
  [Help] List of Lists not printing both Cmder/Anaconda? vanicci 4 4,553 Aug-15-2018, 03:00 PM
Last Post: vanicci

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020