Jul-02-2018, 07:02 PM
Since you were given a lot of advice, just some details about this code
(Jul-02-2018, 05:50 AM)juliabrushett Wrote:def countDigits(s) : digits = 0 x = len(s) for i in range(0, x, 1) : ((ord(s[i]) >= 65) and (ord(s[i]) <= 57)) <----- This line does nothing digits += 1 if s.isdigit() == False : digits -= 1 break else: <--- This is parasitic continue return digits s = input("Enter a string\n") print("There are", countDigits(s), "digits in your string.")
Test everything in a Python shell (iPython, Azure Notebook, etc.)
- Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
- Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
- You posted a claim that something you did not test works? Be prepared to eat your hat.