Skip to main content

Posts

Showing posts with the label on

Python Hunter, Slicing, traversing, copy and pit falling of list and tuple in python. By Pran Sukh

Slicing is a technique in python to pick up data from list,tuple and set from desired location. lets make python a bit more beautiful with slicing technique.  Caution :- No animal is hurt during the development of this tutorial :)   it can be done with three arguments.  e.g dataString [ begin : end : step ] argument begin and end are giving lucid  view, these arguments are to instruct the script that from where the slicing will begin and where it will end, but the tricky argument is the last one ( " step ") . it indicates that how many  index or indices  the code have to   hops or skip to pick up the next slice. In the below example the slicing is starting form 6th index or indices and go till 21th  index and after every slice it will skip the 3 index or indices between the begin and end index.  let's take an example :- 1 25 str = "1abcdefghijklmnopqrstuvwxyz" print ( str [ 6 : 21 : 3 ]) list_1 = [ "T...