Python Forum
How to exclude characters when counting digits
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to exclude characters when counting digits
#17
(Jul-03-2018, 01:29 PM)ichabod801 Wrote: On further examination, both my functions are giving the wrong answer, so they shouldn't be considered.

I'm on comute, so would you timeit this one
def ick_count(text):
    return sum(text.count(digit) for digit in string.digits)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: How to exclude characters when counting digits - by buran - Jul-03-2018, 01:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Counting the number of occurrences of characters in a string nsadams87xx 1 2,024 Jun-16-2020, 07:22 PM
Last Post: bowlofred

Forum Jump:

User Panel Messages

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