Line 3 above should not have
def in front of the call. Just the call itself.
To see the returned string,
print() the call expression.
print (repeat_stuff( ..., ... ))
Whoa! That helped. Thank you. Can you explain me more about SCOPE i couldn’t understand it properly.
Do you have some context to go along with that question?
Above there are two different scopes.
current_year is in global scope, and
birth_year is locally declared, so in local scope. Scope describes where variables can be accessed. In the above example our function has access both to the global and to the local variables declared within its parameter (or within the body of the function).
If we added one more print statement we would see the error message telling us the variable is undefined.
We cannot go down the scope chain, only up.
Thank you.Well i see you answering every questions. Are you a Harvard or Stanford lecturer.
You see a lot of answers because I’ve been here for more than five years (eight, actually) and usually contribute between ten and twenty answers a day. And, no, I am not a lecturer, but flattered by the suggestion. In truth I’m a retired tradesman and lifelong learner dedicating some of my time to working with beginners in the dev field.
Your doing a great job sir helping people complete their task. There aren’t many people like you who after retirement stay so much active. Your mindset of learning for lifelong makes me wonder. I am just 16. I need a lot of help from you can i just DM you sir.
We would prefer questions appear in the forums so others can participate and learn from them. I won’t reject your DMs, though. It will be a case by case decision.
Yeah I understand. Thank you for your immediate response.
Sir or i may call you professor how did you learn to code.
Not professor, no. I have no teaching credentials. Code was something I got drawn into through need. After having built static webpages for a few years I was faced with the problem of making the spam disappear from our inboxes. My first decent achievement was writing a script to replace static links with email addresses. The links would go to the contact page if the script didn’t run, and for bots to find in the source listing. The script would match the id of the link to a table in the script and overwrite the link with the email addy. Spam gone. In the twelve years I had the script running on several sites we got zero spam during the whole time.
It wasn’t through taking a course, but through addressing a pressing need and I learned only as much as I needed to in order to fulfill the requirements. JS was very new to me but I focused only on the things that would get me through my problem.
Gradually that expanded to other types of behavior and interaction but it wasn’t until years later that I would get into AJAX for another project.
The same pressing need brought in PHP around 2008 and again I only learned as much as I needed to know in order to mechanize the server-side and deliver dynamic pages using my own data retrieval methods, no database. It wasn’t until I joined CC that I began to learn from the ground up, and unlearn some of my old misconceptions and bad habits.
Bottom line, for me it was need that pressed me into learning code, and just enough desire to see a thing through to completion. Find a need, then set about to fill it. Think small, not big. Think necessity, not eye-candy or bells and whistles.
Awesome! You have a lot of experience sir. But what i meant by professor is your like a professor to me. But I suggest you to join a college as a professor. You are very well experienced person and your explanation is very good.You will help many young generations and you can learn many more things in that way. Very good luck for that my professor. Best wishes.