DEV Community

kavin suresh
kavin suresh

Posted on

Python List

Empty List

In python it means that a list which is empty.

packages=[]
''
Enter fullscreen mode Exit fullscreen mode

List

List means there are many things which are there in the list.
eg:
list
123
235
574
665

List in Python

eg:

packages=["fruits","vegetables","notebooks"]
Enter fullscreen mode Exit fullscreen mode

Accessing Single List

eg:

packages=["fruits","vegetables","notebooks"]
item=packages[1]

'fruits'
Enter fullscreen mode Exit fullscreen mode

Append() Method

eg:

packages=["fruits","vegetables","notebooks"]
packages.append("pencils")

packages=["fruits","vegetables","notebooks","pencils"]
Enter fullscreen mode Exit fullscreen mode

Remove() method

eg:

packages=["fruits","vegetables","notebooks","pencils"]
packages.remove("fruits")

packages=["vegetables","notebooks","pencils"]
Enter fullscreen mode Exit fullscreen mode

Pop() Method

eg:

packages=["vegetables","notebooks","pencils"]
last_package=packages.pop

packages=["vegetables","notebooks"]
Enter fullscreen mode Exit fullscreen mode

Finding Position by using Index() Method

eg:

packages=["vegetables","notebooks"]
position=packages.index("vegetables")

'1'
Enter fullscreen mode Exit fullscreen mode

Sort() Method

It used to use the list in alphabetical order.
eg:

packages=["fruits","vegetables","notebooks","pencils"]
packages.sort()

["fruits","notebooks","pencils","vegetables"]
Enter fullscreen mode Exit fullscreen mode

This things and all I learn in my class.
Thank You.
S. Kavin

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay