Expected get_length to return 4 for the string ‘test’. Instead it returned None. Why?

Why I am getting this error, " Expected get_length to return 4 for the string ‘test’. Instead it returned None." instead of it when I run my code on VS Code it will give the output “4”.

Here’s my code -

def get_length(string):

count = 0

for i in string:

    # print(i)

    count += 1

print(count)

x = “Test”

get_length(x)

A function without a valid return (or yield) will always return the None object.

1 Like

Thanks for ur reply :slight_smile: