Python Tutorial for Beginners 17 - Python Slice and Negative index

preview_player
Показать описание
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!
Рекомендации по теме
Комментарии
Автор

The thing that I like about python is that it is very intuitive and a lot of the functions that it has actually makes sense. The slice() function works actually like a slice of something... a slice of cake for example :v

danieloliveira
Автор

I got confused on that -3 thing so you mean it stops at - 3 so 7, so it dont print 7 as it is like a stop sign?

oddity
Автор

How can you slice tuples when there is no indexing in tuples ?

Anirudh
Автор

I would have liked to watch the ending of the video but you blocked the whole screen with links to other videos so I won't be watching any of those other videos now .

cornpopthebaddude
Автор

sir please make dsa in python video lecture .

PrakashKumar-pfst
Автор

Shouldn't this be titled as episode 17?

dilucide