Hi 👋, I'm a software engineer specializing in backend systems, distributed systems, and scalable architecture. My blog shares practical tutorials based on 3+ years of experience. LeetCode 1756 (Top 10%). Actively seeking SDE roles — let's get in touch!
Comments
Leave a Comment
Success!
Receive Latest Updates 📬
Get every new post, special offers, and more via email. No fee required.
You may see some code in Python like list[-1], list[:n], list[-n:], or list[::-1]. What do they mean? In this article, we will learn more about this technique which is called list slicing.
In simple words, the meaning of those expressions is:
list[-1]: get the last element of the list
list[:n]: get the first n elements of the list
list[-n:]: get the last n elements of the list
list[::-1]: reverse the list
Keep reading to understand more how list slicing works.
Comments