What is List Slicing in Python | EP-19 List Slicing in Python | How to Slice Lists in Python

Subscribers:
27,900
Published on ● Video Link: https://www.youtube.com/watch?v=0BLzuYyo-Ug



Duration: 12:41
92 views
2


Slicing of a List

We can get substrings and sublists using a slice. In Python List, there are multiple ways to print the whole list with all the elements, but we use the Slice operation to print a specific range of elements from the list. 

Slice operation is performed on Lists using a colon(:). 

To print elements from beginning to a range, use:

[: Index]

To print elements from the beginning to the negative range, use the following:

[:-Index]

To print elements from a specific Index till the end, use 

[Index:]

To print elements from a specific negative Index till the end, use

[-Index:]

To print the whole list in reverse order, use 

[::-1]

Note – To print elements of the List from the rear end, use Negative Indexes. 

Python program to demonstrate
Removal of elements in a List


Creating a List
company = ['c','y','b','r','o','s','y','s']
print(company)
print(len(company))

Printing elements from
beginning till end
print(company[:])
print(company[::])​

Print elements of a range
using Slice operationprint(company[3:8])

Print elements from a
pre-defined point to end
print(company[5:])

Negative index List slicing

Print elements from beginning
to a pre-defined point using Slice
print(company[:-6])


Print elements of a range
using negative index List slicing
print(company[-6:-1])


Printing elements in reverse
using Slice operation
print(company[::-1])

#python #list #listslicing #pythonprogramming #coding #programming #tutorial #learntocode #datascience #pythontips #python3 #pythontutorial #pythoncode #pythondeveloper #pythonista #LearnPython #CodingForBeginners #TechEducation

Connect With Us:
—————————————
➡️ Website: https://www.cybrosys.com/
➡️ Email: info@cybrosys.com
➡️ Twitter:   / cybrosys  
➡️ LinkedIn:   / cybrosys  
➡️ Facebook:   / cybrosystechnologies  
➡️ Instagram:   / cybrosystech  
➡️ Pinterest:   / cybrosys  




Other Videos By Cybrosys Technologies


2024-07-30What is List Comprehension in Python? | EP-21 List Comprehension in Python | Free Python Tutorials
2024-07-30How to Set Up Recruitment Survey Form in Recruitment Software for Free | Horilla HRMS Software
2024-07-29How to Configure Storno Accounting in Odoo 17 | Storno Accounting in Odoo 17 | Odoo 17 Accounting
2024-07-29How to Create a Candidate in Recruitment Software for Free | Best Recruitment Software |Horilla HRMS
2024-07-29Odoo 18 New Features | Expected Features in Odoo 18 | Odoo 18 Upcoming Features | EP-2 Tech Tonic
2024-07-28How to Find the Second Largest Number in a List | EP-20 Find the Second Largest Number in a List
2024-07-28How to Schedule an Interview in Recruitment Software for Free | Best Interview Scheduling Software
2024-07-28Invoice/Bill Wizard in Odoo 18 Purchase Module | Odoo 18 New Features | Odoo 18 Latest Features
2024-07-25Signature Request in Odoo 18 | How to Request an Online Sign to Confirm Orders| Odoo 18 New Features
2024-07-25Pricer Store in Odoo 18 POS | How to Configure Pricer Store in Odoo 18 POS | New features in Odoo 18
2024-07-24What is List Slicing in Python | EP-19 List Slicing in Python | How to Slice Lists in Python
2024-07-23Cloud Storage Application in Odoo 18 | Cloud Storage App in Odoo 18 | Latest Features in Odoo 18
2024-07-23Confirm & Reset Button for Selecting Multiple Companies in Odoo 18 | New Features in Odoo 18
2024-07-22What are List Operations in Python | EP-18 List Operations in Python | List Methods In Python
2024-07-22How to Scan CV Using AI in Odoo 18 | Artificial Intelligence to Scan CV | New Features in Odoo 18
2024-07-22How to Create Approval Type in Odoo 17 Approval | What are the Different Approval Types in Odoo 17
2024-07-21How to Count Records Using Search Count in Odoo 17 | Odoo 17 Development Tutorials | Search_Count()
2024-07-21How to Restore Project History in Odoo 18 | Latest Features in Odoo 18 | New Features in Odoo 18
2024-07-18How to Configure Inventory Operation Types in Odoo 17 |What are Warehouse Operation Types in Odoo 17
2024-07-18How to Take User Input in a List in Python | EP-17 Taking Integer Input in Python List | Python List
2024-07-17What is List in Python | EP-16 List in Python | How to Create List in Python | Lists Functions



Tags:
List Slicing Python
How To Slice Lists In Python
Python Lists
Python Tutorial
Python Programming
Learn Python
Python For Beginners
Python For Data Science
Python Code Examples
Python List Methods
Python List Operations
Python List Comprehension
Python Slicing Syntax
Python
List Slicing
Python List Slicing
Coding
Programming Tutorial
Python Tips
Tech Education
Python Series
Coding For Beginners
Python Basics
Python Slicing Tutorial
Free Python Videos