Hi, I’m new to this. Well, I was revising through this chapter and wanted to check if I really understood the solution. I have already looked around for the explanation, so I’m pretty sure I get it. The problem is when I want to print the counter to see how many letters there are. I keep getting “1” . Surely, in this example I should get at least “5”. No? Is there another way of checking the counter??
counter = 0
for letter in word:
counter += 1
Your indentation isn’t clear here, please look at How do I format code in my posts? which shows how to format code on the forums (for indentation reliant code like Python this is very useful ).
The fact your count only reaches 1 suggests your function is exiting sooner than you expect. Remember that when
return is executed the function is finished and a value is passed back to the caller? Double check when this statement is executed.
Thank you, I hadn’t considered the indentation. It was indented but in the wrong place.
Thank you so much!