Python: Lists output methods

Hi Guys

I wrote this code in one of the exercises
Lists of List

heights = [[‘Jenny’, 61], [‘Alexus’, 70], [‘Sam’, 67], [‘Grace’, 64], [‘Vik’, 68]]
ages = [[‘Aaron’, 15], [‘Dhruti’, 16]]
lets_try = [heights, ‘Titoo’, 87]
print (list(lets_try))
print (’\n’)
print (lets_try)

I got this output

[[[‘Jenny’, 61], [‘Alexus’, 70], [‘Sam’, 67], [‘Grace’, 64], [‘Vik’, 68]], ‘Titoo’, 87]

[[[‘Jenny’, 61], [‘Alexus’, 70], [‘Sam’, 67], [‘Grace’, 64], [‘Vik’, 68]], ‘Titoo’, 87]

There is no difference at all!
Does that mean both methods for o/p are same or does this imply that it is so in this case only?
If it is this case, what has really happened during the output?

From the documentation:

Using the type constructor: list() or list(iterable)

The constructor builds a list whose items are the same and in the same order as iterable ’s items. iterable may be either a sequence, a container that supports iteration, or an iterator object. If iterable is already a list, a copy is made and returned, similar to iterable[:] .

try print([lets_try])

Thank you for your reply

I am not at the level to understand iterable object. Please explain what it means.
I understood from iteration is something that can be counted or used in a loop.
What is a iterable object or iterator object.

You do have Search at your disposal, and the documentation is pretty clear on what is iterable or not.

An iterable object is one that consists of elements that can be enumerated (indexed) such as a list, set or tuple, or consists of items that can be iterated by key-value such as a dictionary.

String objects can iterated, but they are not classified as iterables. Read up on the distinction.

We can run an iterator on any iterable object. is one such iterator we use a lot. The process of iteration is based upon there being a next element or item to jump to. Generally speaking, there would not be a break in the iteration but would run through the entire object from end to end.

for i in range(10):

range returns an iterator, which if we cast it to a list will then give us an iterable. We don’t need a list to run the for loop since we have an iterator, already. The loop above will start at 0 and loop through all the way to 9, carrying out a program instruction on each iteration.