Final answer:
The completed function iterates over each character of a string, checks if the character is an alphabetic letter using the .isalpha() method, and returns the total count of such letters.
Step-by-step explanation:
The task is to complete a Python function that counts the number of alphabetic characters in a given string. The code should include a for loop to iterate through each character in the string and an if statement to check whether a character is an alphabetic letter using the .isalpha() method. Here is the completed function:
def alpha_length(string):
count_alpha = 0
for character in string:
if character.isalpha():
count_alpha += 1
return count_alpha
When called with different strings, such as "This has 1 number in it", "Thisisallletters", or "This one has punctuation!", the function will return the count of letters in each string, ignoring numbers, spaces, and punctuation.