16/18 question..same code, different result


#1

Um… 1-10 is codeacademy “get code” code which prints "MichaelLieberman, and 14-22 is mine that only prints “Michael” as you can see… Not sure why, i saw other topic about same thing and answer with range(len)… but i wonder why this one doesnt work for me if it works fine when i "get code"
Sorry if am asking questions that already have been asked, but i am clueless :confused: … Thanks.


#2

By default, a function returns None at the end of the function. If we want to return something else at the end of the function, we can use the return keyword.

Given return is the last thing a function does, when a return keyword is reached, the function ends

so, because you placed return inside the loop in your code, the function ends in the first iteration of the loop


#3

Saw that return seconds after i posted this… blind i am…

And oo… i didnt know that. Thank you.


#4

attention programming requires.

A small mistake can have big consequences. I spend an hour this week to find a bug in my code, turn out to be a single space character in a space where it wasn’t allowed :frowning:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.