[Tutor] Question

Don Jennings dfjennings at gmail.com
Tue Jul 23 19:45:05 CEST 2013


On Jul 21, 2013, at 10:26 PM, Amandeep Behl wrote:

> 
> 
> def Move(label):
>   label = "Anything"
> 
> a_list = [1,2,3]
> Move(a_list)
> 
> I don't see any error when executing above but  when i manually assign [1,2,3] = "Anything" i get error
>  Why?

Repeat after me:  label is a name, label is a name, label is a name ;>)

So, you misunderstand what is happening in your code. Your function accepts the argument named "label", but you do nothing with the object (a list of numbers in this case). Instead, you use the same name and assign it to the string object "Anything".

Assignment works by assigning a name (on the left side of the operator), to an object on the right side.

Take care,
Don



More information about the Tutor mailing list