8 slicing_operations

 


'''

1. Using slicing operation we can get range of values from list and 

sub string from string.

'''


l = [7,89,34,2,5,12,7]



print(' \n ', l[1:5])

# print(' \n ', l[2:6])

# print(' \n ', l[1:70])

# print(' \n ', l[3:])

# print(' \n ', l[0:5])

# print(' \n ', l[:6])

# print(' \n ', l[:-4])

# print(' \n ', l[-2:-4])

# print(' \n ', l[-4:-2])

# print(' \n ', l[0:6:2])

#print(' \n ', l[::3])

# print(' \n ', l[::-1])

#print(' \n ', l[::-3])


## Slicing operation on string

s = 'sriram'


print(' \n ', s[::-1])


#print(' \n ', s[0:3])









Comments

Popular posts from this blog

1 PYTHON PROGRAMMING

4 Tuple data types

2 String data types