I am curious as to what would occur differently in the code below when
return is executed at either level on indentation. I am having trouble determining where to place
return when writing my functions and would love some clarification on this topic! Thanks in advance
word = 'Hello' def get_length(string): ---count = 0 ---for letter in string: ------count += 1 ------return count
def get_length(string): ---count = 0 ---for letter in string: ------count += 1 ---return count
- What is happening that is different when
returnis indented by 6 dashes (-) vs only 3 dashes and why?
- Also, originally I had `count = 0’ defined outside of the function but received an error. Why does it need to be in the function to execute properly?