Python Forum

Full Version: print number of a list line per line
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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
I have not think to that, is logic. thank for the reply!