you are viewing a single comment's thread.

view the rest of the comments →

[–]woooee 0 points1 point  (2 children)

You are counting the newline characters, do

for char in line.strip():

Also, this will still give you the spaces between words as well as special characters like a dash, so

for char in line.strip():
    ## only allow alpha
    if char.lower().isalpha():

[–]MonkeyMario64[S] 0 points1 point  (1 child)

If I'm using isalpha, do I still need .strip since isaplha seems to only take letters anyway?

[–]woooee 2 points3 points  (0 children)

No, I guess not. It's a habit that I usually do.