Jul-02-2018, 11:34 AM
(This post was last modified: Jul-02-2018, 11:34 AM by gruntfutuk.)
As you are dealing with a string, you can iterate through it with just:
As isdigit() returns True or False, you only need:
For future information, you could replace it all with just a return line:
for character in s:character takes each character in turn in the loop.
As isdigit() returns True or False, you only need:
if character.isdigit(): digit += 1inside the loop.
For future information, you could replace it all with just a return line:
return sum(c.isdigit() for c in s)
I am trying to help you, really, even if it doesn't always seem that way