Data type in Python part -4

For professionals and Experienced 


x="Govind"

Note : In Python Indexing in both direction , from left to right  positive indexing and from right to left negative indexing .
In Python we can move from left to right and right to left , in both direction.

left to right == > G-0 , o-1 , v-2, i-3, n-4, d-5
right to left == > G= -6, o= -5, v= -4, i= -3, n=-2, d=-1.

Example :

x="Govind"
x[1]
output: o

x[-1]
output: d

x[12]
output: index error

s[2:4]  [begin index: end index]
output:  vi
reason: start from 2 index and go up to end index-1

s[1:]
 output: ovind
reason: in this example we not provide end index , hence start from start index and go up o end index

s[:4]
output : Govi
reason: start from start index till end index-1

s[:]
output: Govind
reason : start from strat till end


Example 2:
x="technohubsoftwaresolutions"
s[1:10:2]
output: ehous
reason : start from 1 to 9 with step 2

 Example3:
x="govind"
len(x)
output- 6




   

Comments

Popular posts from this blog

Filter In Javafx

Kotlin with StandAlone Complier