Any advice would be helpful

python

#1

HI,

I am totally new to any form of coding and struggling with every level of this course. Nothing seems to make any sense. People talk about Global and Local and seem to understand at least some of what's going on Can anyone offer any advise on how I can get this coding to stick in my head? I go from one section to another section and totally lose myself. If there is a way to do this more effectively I would love to hear about it.


#2

I find it easier to understand if I "Talk it out", in plain English, what I'm going to do. Say you wanted to return "Illuminati" everytime you were given a multiple of three. I would say,

I need to write a function, that tests an input of a list, to see if a number is divisible by three. If so, then I will return "Illuminati".

JavaScript:

var three_test = function(list1) { 
    for (var number in list1) {
        if (number % 3 == 0) {
            return "Illuminati";
        }
        else {
            return number;
        }
    }
}

Python:

def three_test(list1):
    for number in list1:
        if (number % 3 == 0):
            return "Illuminati"
        else:
            return number

#3

Thank you for your response. Not sure if this will help; will certainly try it out.