Last active
August 29, 2015 14:21
-
-
Save RobColeman/2babd0fad3d7f01f3d7e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for x in "asdfasdfas2343asdf232dfasdf": print(x.isdigit()) | |
def how_many_numbers_in_the_word(word): | |
counter = 0 | |
for x in word: | |
if x.isdigit(): | |
counter = counter + 1 | |
return counter | |
how_many_numbers_in_the_word("this_has_no_number") | |
how_many_numbers_in_the_word("this_has_1_number") | |
how_many_numbers_in_the_word("th1s_has_2_numbers") | |
how_many_numbers_in_the_word("th1s_has_2_numb3rs") | |
# if you wanted to NOT return the count, and only print | |
def how_many_numbers_in_the_word_print(word): | |
counter = 0 | |
for x in word: | |
if x.isdigit(): | |
counter = counter + 1 | |
print counter | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment