Python Forum
print number of a list line per line
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
print number of a list line per line
#1
I have some trouble with my list. I need to print the number line per line. the list looks like that.
[16, 1, 1, 3, 6, 5, 87, 4, 83, 0, 2, 7, 86, 54, 32, 78, 45, 21, 23, 41, 35, 76, 90] #the name of the list is y
I have tried that
y=list(map(int, y))
y=str(y)
y=int(y)

f = sftp.open("/home/pi/SiteCyberdependance/data/data.txt", "w+")
with sftp.open("/home/pi/SiteCyberdependance/data/data.txt", "w") as f:
    for line in f:
            sftp=paramiko.SFTPFile.write
            f.write(y[z])
            z=z+1
the program write that in my file
16, 1, 1, 3, 6, 5, 87, 4, 83, 0, 2, 7, 86, 54, 32, 78, 45, 21, 23, 41, 35, 76, 90]
I need the numbers in my file looks like that.
16
1
1
3
6
5
87
4
83
0
2
7
86
54
32
78
45
21
23
41
35
76
90
and I need to increment the number of my choice, I have tried that.
g=[1,0,0,0,0,0,0,0,0,0,0,0,0]
y=y+g #I do that because y+g don't work
its result to add the content of list g at the end of the list y.
thank for the help. I know is a lot of stock, but I wanted to explain it well.
python 3.7.2
Reply
#2
my_list = [16, 1, 1, 3, 6, 5, 87, 4, 83, 0, 2, 7, 86, 54, 32, 78, 45, 21, 23,
           41, 35, 76, 90]

for item in my_list:
    print(item)
Output:
16 1 1 3 6 5 87 4 83 0 2 7 86 54 32 78 45 21 23 41 35 76 90
Reply
#3
I have not think to that, is logic. thank for the reply!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Line graph with two superimposed lines sawtooth500 4 316 Apr-02-2024, 08:56 PM
Last Post: sawtooth500
  How to add multi-line comment section? Winfried 1 196 Mar-24-2024, 04:34 PM
Last Post: deanhystad
  break print_format lengthy line akbarza 4 361 Mar-13-2024, 08:35 AM
Last Post: akbarza
  Reading and storing a line of output from pexpect child eagerissac 1 4,235 Feb-20-2024, 05:51 AM
Last Post: ayoshittu
  coma separator is printed on a new line for some reason tester_V 4 484 Feb-02-2024, 06:06 PM
Last Post: tester_V
  problem with spliting line in print akbarza 3 377 Jan-23-2024, 04:11 PM
Last Post: deanhystad
  Unable to understand the meaning of the line of code. jahuja73 0 303 Jan-23-2024, 05:09 AM
Last Post: jahuja73
  Receive Input on Same Line? johnywhy 8 710 Jan-16-2024, 03:45 AM
Last Post: johnywhy
  Reading in of line not working? garynewport 2 832 Sep-19-2023, 02:22 PM
Last Post: snippsat
  'answers 2' is not defined on line 27 0814uu 4 726 Sep-02-2023, 11:02 PM
Last Post: 0814uu

Forum Jump:

User Panel Messages

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