Python List Slicing Explained With Example
- What is Python Programming Language? Definition and Introduction
- Python Advantages: What Are Benefits of Using Python Programming?
- Top 10 Uses & Applications of Python Programming Language (With Examples)
- Python Installation Process: How to Download & Install Python?
- Python Keywords List (All Keywords in Python With Examples)
- What is Python Statement?
- What is Indentation in Python Programming? Examples, Rules, Pros & Cons, Full Guide
- What are Python Comments? Explained in Simple Terms
- Python Variable Name Rules
- What Are Namespaces in Python? Namespace vs Scope (Meaning, Examples)
- What is Multithreading in Python? Examples, Benefits, Uses
- What Are Operators in Python? What Are Different Types of Python Operators
- What Are Python Arithmetic Operators? Types of Arithmetic Operators With Example
- What is Python Assignment Operators? Full List With Types and Examples
- What Are Python Comparison or Relational Operators? With Example
- Python Logical Operators: Full List With Examples
- Python Bitwise Operators (Explained With Example)
- Python Special Operators (Identity & Membership Operators): Explained With Examples
- Python Ternary Operators: Explained With Example
- Python Data Types: List of Data Types With Example
- What are Python Numbers? int, float, complex
- What are Python Strings? How to Create String in Python?
- What Are Python Lists? How to Create List in Python?
- What Are Python Tuples? How to Create Tuple in Python?
- Python Sets: Functions, Operations, and Examples
- What is Python Dictionary? How to Create Dictionary in Python?
- What is Python Type Conversion? Explained With Example
- Python Strings With Examples
- Python String Concatenation Explained with Examples
- Python String Slicing Explained with Examples
- Delete or Change a String in Python with examples
- String Formatting in Python With Examples
- Python String Methods With Examples
- Python Escape Characters Explained Using repr(), Using “r/R”
- Python List With Examples
- Adding Elements to Python List Using append(), insert() and extend(), Method
- Accessing Elements From Python List
- Delete/Remove Elements From Python List
- Python List Slicing Explained With Example
- Iterate a Python List With Example
- Python List Comprehension Explained With Example
- Python Nested List Explained With Examples
- List Methods in Python Explained With Example
- Tuples in Python Explained With Examples
- Accessing Tuple Items in Python
- Python Tuple Slicing Explained With Examples
- How to Update Tuple in Python? Change Tuple Value or Modify It
- Unpacking a Tuple in Python Explained With Examples
- Python Concatenation of Tuples
- Changing and Deleting Tuple Item Values
- Python Tuple Methods Explained WIth Example
- Python Functions - Syntax and How To Call Python Function
- Types of Python Functions With Code Examples
- Python Function Arguments Explained With Examples
- Recursion and Recursive Function in Python
- What is Lambda Functions in Python and How to Use It
- Python Modules- How to Create, Use and Variables
- Python Packages- How to Create and Uses
- Understanding Python OOPS Concepts
- Python Inheritance OOPS - (Multiple and Multilevel Inheritance)
- Python Interators Explained With Examples
- Python Encapsulation Explained With Examples
- Python Polymorphism Explained WIth Examples
- Objects and Classes in Python OOPS
- Python Constructors and Their Types
- __init__() Function in Python
- Python Object Methods Explained With Example
- Python Self Parameter Explained With Example
- Deleting Attributes and Objects in Python
- Introduction to Python Tkinter Explained [With Example]
- What Are Widgets in Tkinter in Python?
- What is Geometry and Layout Management & Widgets in Tkinter in Python
- What is Binding Functions in Python Tkinter?
- What Are Mouse Clicking Events in Python Tkinter? [With Examples]
- Step by Step Create Drop-Down Menus in Python Tkinter
- What is ktMessageBox in Python Tkinter with Example
- Understanding Shapes, Images, Icons in Tkinter
How to Slice a List in Python?
Slice operation is done on lists with the use of a colon(:). If you want to print elements from beginning to a range, use [: Index]. To print elements from the end, use [:-Index].
Alternatively, if you want to print elements from a specific Index till the end, use [Index:]. To print elements within a range, use [Start Index:End Index].
Lastly, if you want to print the whole List with the use of slicing operation, use [:].
For printing the whole list in reverse, use [::-1].
text = 'Python Programing' # get slice object to slice Python sliced_text = slice(6) print(text[sliced_text])