leftPart 1fgh0C1ert rightPart 22AB3 result def gramma string while len

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
leftPart = "1fgh0C1ert"
rightPart = "22AB3"
result = []
def gramma(string):
i = 0
while i != len(string):
if string[i].isdigit() or string[i].islower():
t = string[i]
i += 1
for j in string[i:]:
if j.isdigit() or string[i].islower():
t += j
i += 1
else:
break
result.append("<{0}, {1}>".format(0, t))
else:
result.append("<{0}, {1}>".format(1, string[i]))
i += 1
if __name__ == '__main__':
gramma(leftPart)
gramma(rightPart)
for i in result:
print ileftPart = "1fgh0C1ert"
rightPart = "22AB3"
result = []
def gramma(string):
i = 0
while i != len(string):
if string[i].isdigit() or string[i].islower():
t = string[i]
i += 1
for j in string[i:]:
if j.isdigit() or string[i].islower():
t += j
i += 1
else:
break
result.append("<{0}, {1}>".format(0, t))
else:
result.append("<{0}, {1}>".format(1, string[i]))
i += 1
if __name__ == '__main__':
gramma(leftPart)
gramma(rightPart)
for i in result:
print i