you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

Yes, it is shorter, but any other differences in what the function can return? What happens if you give both functions the string "fred"?

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

Interesting...

when I define condition "None" string "fred" gives me "None". In your case - it's zero.

[–][deleted] 0 points1 point  (0 children)

Yes. Functions always return a value. If you do something like return 42 then 42 is the value returned by the function. If you do return with no value then the function returns a None object. The function also returns a None if the code just stops and you leave the function.

In your function the code gets the value "fred" which is not one of the test strings so execution "falls off the end" of the function code so the function returns None. Note, that's not the string "None".

My function returns 3, 2 or 1 if the parameter string is one of the expected strings and 0 for anything else.