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
  No new line from print in a browser Lou 13 1,366 Dec-01-2025, 06:39 PM
Last Post: noisefloor
  [split] print two different sequence number Reema 1 686 Nov-10-2025, 05:37 AM
Last Post: Gribouillis
  cannot unpack non-iterable int object in urllib3/util/wait.py", line 85, ping_chen_ibm_us 2 931 Aug-01-2025, 02:05 PM
Last Post: ping_chen_ibm_us
  [SOLVED] Why does regex fail cleaning line? Winfried 7 4,937 Jul-11-2025, 11:52 PM
Last Post: Pedroski55
  I am a newbie I like to use the command line Mikel2025 1 1,063 Jun-13-2025, 03:20 PM
Last Post: Gribouillis
  Βad Input on line 12 Azdaghost 5 2,237 Apr-19-2025, 10:22 PM
Last Post: Azdaghost
Question [SOLVED] [Beautiful Soup] Move line to top in HTML head? Winfried 0 967 Apr-13-2025, 05:50 AM
Last Post: Winfried
  Insert command line in script lif 4 2,200 Mar-24-2025, 10:30 PM
Last Post: lif
  Entry field random pull from list, each return own line Bear1981 6 1,940 Feb-25-2025, 06:09 AM
Last Post: Pedroski55
  How to revert back to a previous line from user input Sharkenn64u 2 3,184 Dec-28-2024, 08:02 AM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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