What happend to me?



I have a problem. when I print each members of list which is I replaced, it works.
but when I tried to print whole list, the member I replaced isn't changed.
even I already check by printing each members of the list.

I'm from Asia, so maybe you confused what I meant.
so I comment on the line where I stuck to.

Why does this happen? Why does it not change?

Is this issue about memory structure?

I really need your help guys.

def censor(text, word):
    for member in ary:
        if member==word:
        print member    # *****\n my\n load\n
    print ary           # [hello', 'my', 'load']

censor("hello my load", "hello")


is it about 'call by value' and 'call by reference'?

I change to access with index like ary[i] not just member, and it works.


the drawback of using such a for loop:

for member in ary

is that member is variable which gets assigned the words in your list in order, but in each run of the loop it gets re-assigned, and after the loop it cease to exist

If you where to use range() instead, you get indexes which you can use to actually manipulate the list


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