[Solved]Possible reference doubt


#1

Hi, everyone!
A few hours ago I went to topic and saw the following line of code:

student = lloyd, alice, tyler

I thought this was wrong, it would cause some sort of error because the variable student is not a list or anything but it turns out it's correct.
For the record : each element in that "name's list" is a dictionary.

When I tried to check the type of it, it turns out that student, after assigning all that information, it's now a tuple.

Could someone, please, explain why that happened?
I understand about references, at least I think I do now, but I can't a find a solution for it.


#2

It's because it is implicitly a tuple.

Do the following,

def give():
    return 1, 2, 3, 4, 5, 6

This returns a tuple object for the same reason that student = lloyd, alice, tyler assigns a tuple.

Syntax wise any string joined together with a , is a tuple object but we generally add the () so that it is easier to identify the tuple.

Here is the doc about this as I am unwilling at this time to delve deeper into why.

Best of luck.


#3

@zeziba: Thanks for the explanation and the link for it, I'll check it out!
Thanks once again!