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
  Βad Input on line 12 Azdaghost 5 1,315 Apr-19-2025, 10:22 PM
Last Post: Azdaghost
Question [SOLVED] [Beautiful Soup] Move line to top in HTML head? Winfried 0 307 Apr-13-2025, 05:50 AM
Last Post: Winfried
  Insert command line in script lif 4 1,032 Mar-24-2025, 10:30 PM
Last Post: lif
  Entry field random pull from list, each return own line Bear1981 6 847 Feb-25-2025, 06:09 AM
Last Post: Pedroski55
  How to revert back to a previous line from user input Sharkenn64u 2 1,018 Dec-28-2024, 08:02 AM
Last Post: Pedroski55
  Pandas - error when running Pycharm, but works on cmd line zxcv101 2 2,470 Sep-09-2024, 08:03 AM
Last Post: pinkang
  Simplest way to run external command line app with parameters? Winfried 2 1,320 Aug-19-2024, 03:11 PM
Last Post: snippsat
  Printing the code line number arbiel 6 1,678 Jun-30-2024, 08:01 AM
Last Post: arbiel
  How to add multi-line comment section? Winfried 2 1,392 Jun-04-2024, 07:24 AM
Last Post: Gribouillis
Information Is it possible to multi line a Basic Function Construct line statement? If so how? BrandonKastning 7 2,030 May-23-2024, 03:02 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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