Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
count item in list
#1
Hello,
how can I count part of items in list?

to be clear :
I have a list that build in this form
Final_List= [['10.0.0.1:Success', '10.0.0.2:Success', '10.0.0.3:Error', '10.0.0.4:Offline' , '10.0.0.5:Error']]

I want to know how much Succes\error\offline there is in the list (i don't mind the IP - just the total number)
I have try to run

ok = 0
error = 0
offline = 0 
for item in IP_List:
    if 'Success' in item:
        ok +=1
    if 'Error' in item:
        error +=1 
    if 'offline' in item:
        offline += 1 
maybe I used list.appand wrong?
Final_List.append(p.map(GetUplaudFies, Device_List))
GetUplaudFies return this
 return ip + ":" + Upload_Status
Reply


Messages In This Thread
count item in list - by korenron - Jun-30-2021, 01:23 PM
RE: count item in list - by deanhystad - Jun-30-2021, 01:31 PM
RE: count item in list - by korenron - Jun-30-2021, 01:53 PM
RE: count item in list - by deanhystad - Jun-30-2021, 02:04 PM
RE: count item in list - by korenron - Jun-30-2021, 03:22 PM
RE: count item in list - by DeaD_EyE - Jun-30-2021, 03:38 PM
RE: count item in list - by korenron - Jul-01-2021, 08:48 AM
RE: count item in list - by deanhystad - Jul-01-2021, 01:46 PM
RE: count item in list - by naughtyCat - Aug-18-2021, 06:40 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Function to count words in a list up to and including Sam Oldman45 15 6,612 Sep-08-2023, 01:10 PM
Last Post: Pedroski55
  Row Count and coloumn count Yegor123 4 1,336 Oct-18-2022, 03:52 AM
Last Post: Yegor123
  For Word, Count in List (Counts.Items()) new_coder_231013 6 2,620 Jul-21-2022, 02:51 PM
Last Post: new_coder_231013
Question Finding string in list item jesse68 8 1,887 Jun-30-2022, 08:27 AM
Last Post: Gribouillis
  How to get unique entries in a list and the count of occurrence james2009 5 2,994 May-08-2022, 04:34 AM
Last Post: ndc85430
  how to easily create a list of already existing item CompleteNewb 15 3,571 Jan-06-2022, 12:48 AM
Last Post: CompleteNewb
  Remove an item from a list contained in another item in python CompleteNewb 19 5,764 Nov-11-2021, 06:43 AM
Last Post: Gribouillis
  Time.sleep: stop appending item to the list if time is early quest 0 1,882 Apr-13-2021, 11:44 AM
Last Post: quest
  list.count does not appear to function Oldman45 7 3,945 Mar-16-2021, 04:25 PM
Last Post: Oldman45
  How to run a pytest test for each item in a list arielma 0 2,374 Jan-06-2021, 10:40 PM
Last Post: arielma

Forum Jump:

User Panel Messages

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