DEV Community

Arokya Naresh
Arokya Naresh

Posted on

Python tutorial 25.07.2024

SLICING
we can hop btwn letters in the index

        H   e   l   l   o   m   o   b   i   l   e
Enter fullscreen mode Exit fullscreen mode

Positive Indexing 0 1 2 3 4 5 6 7 8 9 10
Negative Indexing -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1

Eg1:
msg='HelloMobile'
print(msg[0:11:2]) -->2 denotes hop (i.e no. of hop inbtwn letter )
print(msg[0:11:3])

o/p
Hlooie
Hlol

Iterable-is a container of value which we can iterate by using loop

eg:
loop='Apple'
for d in loop[1:]:
print(d)

A
p
p
l
e

Here loop is that container which has values Apple.To get to know what is in that loop we use for loop which we can iterate

Top comments (0)