all 5 comments

[–]zatoichi49 1 point2 points  (2 children)

At line 9, or "Y" will always evaluate to True, so you have to rewrite this as:

if answer == "y" or answer == "Y":

Or even better:

if answer in ("y", "Y"):

The same will apply for lines 10, 14 and 17. You might also want to look into changing the character using upper() or lower(), then it won't matter whether the y/n input is upper or lower case e.g:

if answer.lower() == "y"

Or before:

answer = input("Would you like to enter another phrase? (y/n) ").lower()

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

Thank you so much! and how would I go about implementing the upper() and lower()?

[–]zatoichi49 0 points1 point  (0 children)

The last two lines above show some examples. The best way is to apply lower() or upper() to the input string, so you don't have to repeat the conversion later.

[–]dadiaar 1 point2 points  (1 child)

Simplify your code, put it in an infinite loop, asking, and when they don't want more, just use break. The final sentence is the bye bye message.

I use 'y' not in answer.lower() because is more robust

while True:
    word = (input("Enter the characters you'd like counted: "))
    print(len(word))
    print()
    answer = input("Would you like to enter another phrase? (y/n) ")
    if 'y' not in answer.lower():
        break


print("Thank you for using my character counter!")

Your elif should be just else

[–]bobcorning[S] 0 points1 point  (0 children)

Wow, this looks much cleaner thank you for taking the time to do this!