filmov
tv
Python Tutorial for Beginners 17 - Python Slice and Negative index
Показать описание
In this video I am going to show How to use Slice function or slicing with Python Collections. Also I am going to show how to use Negative index with Python Collections. So What is Python Slice? A slize is a span of items that are taken from a sequence
List slicing format: list[start : end: step]. Span is a list containing copies of elements from start up to, but not including, end
If start not specified, 0 is used for start index. If end not specified, len(list) is used for end index. Slicing expressions can include a step value and negative indexes relative to end of list.
And What is Negative Indexing In Python: I a Python Collection such as Lists, Strings, Tuples, Bytes .. we can refer to an element by a negative index representing how far it is from the end.
example
# +---+---+---+---+---+---+
# | P | y | t | h | o | n |
# +---+---+---+---+---+---+
# 0 1 2 3 4 5 ---- Positive Index
# -6 -5 -4 -3 -2 -1 ---- Negative Index
#PythonTutorialforBeginners #ProgrammingKnowledge #LearnPython #PythonCourse
★★★Top Online Courses From ProgrammingKnowledge ★★★
★★★ Online Courses to learn ★★★
★★★ Follow ★★★
DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!
List slicing format: list[start : end: step]. Span is a list containing copies of elements from start up to, but not including, end
If start not specified, 0 is used for start index. If end not specified, len(list) is used for end index. Slicing expressions can include a step value and negative indexes relative to end of list.
And What is Negative Indexing In Python: I a Python Collection such as Lists, Strings, Tuples, Bytes .. we can refer to an element by a negative index representing how far it is from the end.
example
# +---+---+---+---+---+---+
# | P | y | t | h | o | n |
# +---+---+---+---+---+---+
# 0 1 2 3 4 5 ---- Positive Index
# -6 -5 -4 -3 -2 -1 ---- Negative Index
#PythonTutorialforBeginners #ProgrammingKnowledge #LearnPython #PythonCourse
★★★Top Online Courses From ProgrammingKnowledge ★★★
★★★ Online Courses to learn ★★★
★★★ Follow ★★★
DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!
Комментарии