Jump to content
Raktim

What is mean by "ordered" in LIST (Array):-Paython

Recommended Posts

List: collection which is ordered and changeable. But, if I create a list 'car' which is Unordered like that...

car=["BMW","MAHINDRA","HERO","KTM"]
print(car)

SO, it does not support 'list' properties. But print result is  ['BMW', 'MAHINDRA', 'HERO', 'KTM'] .

Please help me that how it works even the 'list' is unordered, why it don't show any error message.

Share this post


Link to post
Share on other sites

The order is the index order the Items are listed, you can insert them any order and it will always display in that same order unless sorted for example using sort().

Share this post


Link to post
Share on other sites
12 hours ago, Raktim said:

SO, it does not support 'list' properties. But print result is  ['BMW', 'MAHINDRA', 'HERO', 'KTM'] .

Expanding on what dsonesuk has said, a more fitting representation of this list is

[
  0: 'BMW',
  1: 'MAHINDRA',
  2: 'HERO',
  3: 'KTM'
] 

It is technically ordered, just not by what you think.

Edited by Funce

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...