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
#18
On my iPad:
print('smart:',timeit.timeit("smart_count_digits(my_string)", setup = "from __main__ import smart_count_digits, my_string", number = 1000))
print('count:',timeit.timeit("count_digits(my_string)", setup = "from __main__ import count_digits, my_string", number = 1000))
print('ick:',timeit.timeit("ick_count(my_string)", setup = "from __main__ import ick_count, my_string", number = 1000))
Output:
smart: 1.1727769580029417 count: 8.195804083981784 ick: 0.5881457919895183
ick_count is the winner.
I am trying to help you, really, even if it doesn't always seem that way
Reply


Messages In This Thread
RE: How to exclude characters when counting digits - by gruntfutuk - Jul-03-2018, 02:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Counting the number of occurrences of characters in a string nsadams87xx 1 1,968 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