Jul-02-2018, 05:01 AM
Hello
I am trying to write a program that will count only numeric digits within a string, excluding all letters. What I have currently counts EVERYTHING. How do I fix this?
I am trying to write a program that will count only numeric digits within a string, excluding all letters. What I have currently counts EVERYTHING. How do I fix this?
def countDigits(digits) : digits = 0 x = len(s) for i in range(0, x, 1) : ((ord(s[i]) >= 65) and (ord(s[i]) <= 57)) digits += 1 return digits s = input("Enter a string\n") print("There are", countDigits(s), "digits in your string.")