Python Forum
Counting number of occurrences of a single digit in a list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Counting number of occurrences of a single digit in a list
#10
Is the following what you were looking for at the beginning?

Paul
import numpy as np

##I build a model
n = 20
A = []
for i in range(n):
    A.append("1")
A[3] = '...1'
A[6] = '...1'

## The list is converted to an array
A = np.array(A)
loc = np.where(A == "...1")
exact_loc = list(loc)[0] # Eureka
Reply


Messages In This Thread
RE: Counting number of occurrences of a single digit in a list - by paul18fr - Aug-07-2019, 05:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [solved] a 4-digit display vr34 2 393 Apr-12-2024, 05:38 PM
Last Post: vr34
  [SOLVED] Pad strings to always get three-digit number? Winfried 2 415 Jan-27-2024, 05:23 PM
Last Post: Winfried
  Delete strings from a list to create a new only number list Dvdscot 8 1,612 May-01-2023, 09:06 PM
Last Post: deanhystad
  find random numbers that are = to the first 2 number of a list. Frankduc 23 3,364 Apr-05-2023, 07:36 PM
Last Post: Frankduc
  prefix ID Number with 0,00 make 3 digit. mg24 1 797 Oct-06-2022, 07:20 AM
Last Post: ibreeden
  TypeError: float() argument must be a string or a number, not 'list' Anldra12 2 4,962 Jul-01-2022, 01:23 PM
Last Post: deanhystad
  Split a number to list and list sum must be number sunny9495 5 2,364 Apr-28-2022, 09:32 AM
Last Post: Dexty
  Divide a number by numbers in a list. Wallen 7 8,141 Feb-12-2022, 01:51 PM
Last Post: deanhystad
  When did the number got included in the list? Frankduc 14 3,243 Feb-03-2022, 03:47 PM
Last Post: Frankduc
  Parse String between 2 Delimiters and add as single list items lastyle 5 3,453 Apr-11-2021, 11:03 PM
Last Post: lastyle

Forum Jump:

User Panel Messages

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