Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Try/Exept prints only ones
#3
Hi, here is an example of input files.


File one :

111111111 Error 0 paaaaa d ffffffff
cv,m dserr
2 333 555555
this is a file 1 Error 0 first file

Second file:
looking for Error 1 in the file
asd 34 nmmmmmmmmmmmm errrrrr
dd m mmmmmmm Error 1 ;;;;;;;;;;;

I'm scanning files for specific lines (with 'Error 0' and "Error 1', If lines found I append them to lists and count matched lines.
I need to print only the last line from each list and the count number (of matched lines).
I'm using Try/Except to handle empty lists and having a problem with "print". The script I wrote prints only one Print statement, Confused I need to print a lot more than one.

If you'll run my snippet, it will print only ones.

I'm trying to print all the last elements from the lists and I cannot.


Thank you!
Reply


Messages In This Thread
Try/Exept prints only ones - by tester_V - Nov-01-2020, 04:13 AM
RE: Try/Exept prints only ones - by bowlofred - Nov-01-2020, 04:40 AM
RE: Try/Exept prints only ones - by tester_V - Nov-01-2020, 05:52 AM
RE: Try/Exept prints only ones - by tester_V - Nov-01-2020, 06:11 AM
RE: Try/Exept prints only ones - by deanhystad - Nov-01-2020, 10:14 PM
RE: Try/Exept prints only ones - by tester_V - Nov-02-2020, 01:58 AM
RE: Try/Exept prints only ones - by deanhystad - Nov-02-2020, 03:41 AM
RE: Try/Exept prints only ones - by tester_V - Nov-02-2020, 03:44 AM
RE: Try/Exept prints only ones - by tester_V - Nov-02-2020, 03:56 AM
RE: Try/Exept prints only ones - by deanhystad - Nov-02-2020, 04:00 AM
RE: Try/Exept prints only ones - by deanhystad - Nov-02-2020, 04:25 AM
RE: Try/Exept prints only ones - by tester_V - Nov-03-2020, 02:38 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  zfill prints extra et the end of a var tester_V 4 931 Mar-24-2023, 06:59 PM
Last Post: tester_V
  variable prints without being declared. ClockPillow 2 1,836 Jul-11-2021, 12:13 AM
Last Post: ClockPillow
  Output prints Account.id at the end? LastStopDEVS 5 2,845 Dec-19-2020, 05:59 AM
Last Post: buran
  loop only prints last character. mcmxl22 1 1,748 Feb-17-2020, 02:36 AM
Last Post: menator01
  can you understand why this code prints None? arcbal 2 2,787 Mar-13-2019, 02:57 AM
Last Post: arcbal
  What for a file that prints nothing sylas 1 2,196 Sep-12-2018, 01:18 PM
Last Post: gruntfutuk

Forum Jump:

User Panel Messages

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