You are on page 1of 1

C:\Users\Rajdeep Baruri\Documents\stringSlice.

txtstringSlice

1 '''
2 Created on 30-Mar-2020
3
4 @author: Rajdeep Baruri
5 '''
6 print("This program divides a string into five parts with some condition mentioned by ")
7
8 def stringDivision(x):
9 print("String division")
10
11 q = len(x) / 5
12 r = len(x) % 5
13
14
15 myList = [q, 2 * q, 3 * q + r, 4 * q + r, 5 * q + r]
16
17 slicedList = []
18 k = 0
19 for i in range(len(myList)):
20 temp1 = []
21 for j in range(k, myList[i]):
22 temp1.append(x[j])
23 k = k +1
24 slicedList.append(temp1)
25
26
27 for i in range(len(slicedList)):
28 print(slicedList[i])
29 return
30
31
32 theString = "IamADiscoDancerChairTablePen"
33 stringDivision(theString)

Page 1/1

You might also like