def substring(s, start, end):"""Remove `start` characters from the beginning and `end`characters from the end of string `s`.
Examples-------->>> substring('abcde', 0, 3)'abc'>>> substring('abcde', 1, None)'bcde'"""return s[start:end]
str1='There you are'>>> str1[:]'There you are'
>>> str1[1:]'here you are'
#To print alternate characters skipping one element in between
>>> str1[::2]'Teeyuae'
#To print last element of last two elements>>> str1[:-2:-1]'e'
#Similarly>>> str1[:-2:-1]'e'
#Using slice datatype
>>> str1='There you are'>>> s1=slice(2,6)>>> str1[s1]'ere '
match_string_len = len(match_string)for index,value in enumerate(main_string):sub_string = main_string[index:match_string_len+index]if sub_string == match_string:print("match string found in main string")
text = "StackOverflow"#using python slicing, you can get different subsets of the above string
#reverse of the stringtext[::-1] # 'wolfrevOkcatS'
#fist five characterstext[:5] # Stack'
#last five characterstext[-5:] # 'rflow'
#3rd character to the fifth charactertext[2:5] # 'rflow'
#characters at even positionstext[1::2] # 'tcOefo'