Professional Documents
Culture Documents
Pytho-LJ-week5
Pytho-LJ-week5
print('part-1 output')
prefixes = 'JKLMNOPQ'
suffix = 'ack'
print(letter + 'u'+suffix)
else:
#part 2
print('output of example-1')
example = 'extrapple'
z = len(example)
#example-1
def one_example():
y=0
while y < z :
print(one_slice)
y = y+1
#for minus index, it starts from -1 value that belong to the last character of the string.
#The minus indexes belonging to characters flow from the last character to the begining of the strings
decreasingly by one.
one_example()
#example-2
print('example-2 output')
two_slice = example[:n]
third_slice = example[n:]
#From adding these slices, checking whether two slices can get back to the original string by
concatenation.
print ('True')
# adding two slices is legal, and by concatenation, the original string can be got back.
re_string(5)
#example 3
print('example- 3 output')
def nested_slice():
x=-1
z=len(example)
v=-z
if x != v:
nested_example = example [x:][x-1:][v:] # nested slics' indexes! The last brackets extracts slics
from the example string.
#The next left side bracket extracts from the next right side bracket's extracted string, and so on
till the begining of the brackets list.
print(nested_example)
x=x-1
else:
print(example)
x=x-1
nested_slice()