0
What is content and reference?
L1=["sachin"]
3 Respostas
+ 6
Hi! L1 is a variable with a referens to a memory adress where a list is stored. The content of the list is the string ”sachin”.
+ 2
Using ’[’ and ’]’ is one way to create a list. Using list() is another way to create a list. For example my_list = [1, 2, 3].
But if you create a list, and want to use it later, you have to store it somewhere in the memory. Python chooses that place for you, and that place has a memory adress.
To make it easy for you, you just create a variable (here my_list), and assign your list to that variable as shown above.
‘Inside’ my_list there is the adress (which you can’t normaly see) to the place in memory where the list is stored. So your variable my_list now containing a referens (the adress) to the list in the memory. And now you can write the name of the variable, instead of create a new list, when you want to use a list like that:
print(my_list)
>> [1, 2, 3]
0
Mean you say that, here the reference is [] list data type and the content is sachin. Am right?