Thay thế mọi chữ cái chữ hoa 'l' trong không gian trống cộng với chữ cái đó "L". Chúng ta có thể làm điều này bằng cách sử dụng danh sách hiểu hoặc chúng ta có thể xác định một chức năng để thực hiện nó như sau.
s = 'TheLongANDWindingRoad ABC A123B45'
''.join[[char if [char.islower[] or not char.isalpha[]] else ' '+char for char in list[s]]].strip[].split[]
>>> ['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road', 'A', 'B', 'C', 'A123', 'B45']
Nếu bạn chọn đi theo một chức năng, đây là làm thế nào.
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
Trong trường hợp của ví dụ đã cho:
print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
Nhưng hầu hết thời gian chúng tôi đang chia một câu ở các chữ cái trên, thường là trường hợp chúng tôi muốn duy trì các chữ viết tắt thường là một dòng chữ in hoa liên tục. Mã dưới đây sẽ giúp.
def splitAtUpperCase[s]:
for i in range[len[s]-1][::-1]:
if s[i].isupper[] and s[i+1].islower[]:
s = s[:i]+' '+s[i:]
if s[i].isupper[] and s[i-1].islower[]:
s = s[:i]+' '+s[i:]
return s.split[]
splitAtUpperCase['TheLongANDWindingRoad']
>>> ['The', 'Long', 'AND', 'Winding', 'Road']
Thanks.
Cải thiện bài viết
Lưu bài viết
Đưa ra một chuỗi, hãy viết một chương trình Python để phân chia chuỗi trên các ký tự chữ hoa. Hãy để thảo luận về một vài phương pháp để giải quyết vấn đề.
Phương thức số 1: Sử dụng re.findall [] phương thức & nbsp;
Python3
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
0 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
1def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
2def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
4def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
5 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
6def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
7def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
8def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
9def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3 print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
1def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
9def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3 print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
4print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
5def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
8def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
5def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
6print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
9def splitAtUpperCase[s]:
for i in range[len[s]-1][::-1]:
if s[i].isupper[] and s[i+1].islower[]:
s = s[:i]+' '+s[i:]
if s[i].isupper[] and s[i-1].islower[]:
s = s[:i]+' '+s[i:]
return s.split[]
splitAtUpperCase['TheLongANDWindingRoad']
>>> ['The', 'Long', 'AND', 'Winding', 'Road']
0def splitAtUpperCase[s]:
for i in range[len[s]-1][::-1]:
if s[i].isupper[] and s[i+1].islower[]:
s = s[:i]+' '+s[i:]
if s[i].isupper[] and s[i-1].islower[]:
s = s[:i]+' '+s[i:]
return s.split[]
splitAtUpperCase['TheLongANDWindingRoad']
>>> ['The', 'Long', 'AND', 'Winding', 'Road']
1def splitAtUpperCase[s]:
for i in range[len[s]-1][::-1]:
if s[i].isupper[] and s[i+1].islower[]:
s = s[:i]+' '+s[i:]
if s[i].isupper[] and s[i-1].islower[]:
s = s[:i]+' '+s[i:]
return s.split[]
splitAtUpperCase['TheLongANDWindingRoad']
>>> ['The', 'Long', 'AND', 'Winding', 'Road']
2Output:
Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']
Phương pháp số 2: Sử dụng Re.Split []
Python3
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
0 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
1def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
2def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
4def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
5 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
6def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
7def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
8def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
9def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3 print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
1def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
5def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
6print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
9def splitAtUpperCase[s]:
for i in range[len[s]-1][::-1]:
if s[i].isupper[] and s[i+1].islower[]:
s = s[:i]+' '+s[i:]
if s[i].isupper[] and s[i-1].islower[]:
s = s[:i]+' '+s[i:]
return s.split[]
splitAtUpperCase['TheLongANDWindingRoad']
>>> ['The', 'Long', 'AND', 'Winding', 'Road']
0def splitAtUpperCase[s]:
for i in range[len[s]-1][::-1]:
if s[i].isupper[] and s[i+1].islower[]:
s = s[:i]+' '+s[i:]
if s[i].isupper[] and s[i-1].islower[]:
s = s[:i]+' '+s[i:]
return s.split[]
splitAtUpperCase['TheLongANDWindingRoad']
>>> ['The', 'Long', 'AND', 'Winding', 'Road']
1def splitAtUpperCase[s]:
for i in range[len[s]-1][::-1]:
if s[i].isupper[] and s[i+1].islower[]:
s = s[:i]+' '+s[i:]
if s[i].isupper[] and s[i-1].islower[]:
s = s[:i]+' '+s[i:]
return s.split[]
splitAtUpperCase['TheLongANDWindingRoad']
>>> ['The', 'Long', 'AND', 'Winding', 'Road']
2
Output:
Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']
9def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
4print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
5print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
8 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
Python3
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
2def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
4def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
5 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
6def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
7def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
8def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
9def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3 print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
1def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
9def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3 print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
4print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
5def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
8Phương pháp số 2: Sử dụng Re.Split []
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
5def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
6print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
9def splitAtUpperCase[s]:
for i in range[len[s]-1][::-1]:
if s[i].isupper[] and s[i+1].islower[]:
s = s[:i]+' '+s[i:]
if s[i].isupper[] and s[i-1].islower[]:
s = s[:i]+' '+s[i:]
return s.split[]
splitAtUpperCase['TheLongANDWindingRoad']
>>> ['The', 'Long', 'AND', 'Winding', 'Road']
0def splitAtUpperCase[s]:
for i in range[len[s]-1][::-1]:
if s[i].isupper[] and s[i+1].islower[]:
s = s[:i]+' '+s[i:]
if s[i].isupper[] and s[i-1].islower[]:
s = s[:i]+' '+s[i:]
return s.split[]
splitAtUpperCase['TheLongANDWindingRoad']
>>> ['The', 'Long', 'AND', 'Winding', 'Road']
1def splitAtUpperCase[s]:
for i in range[len[s]-1][::-1]:
if s[i].isupper[] and s[i+1].islower[]:
s = s[:i]+' '+s[i:]
if s[i].isupper[] and s[i-1].islower[]:
s = s[:i]+' '+s[i:]
return s.split[]
splitAtUpperCase['TheLongANDWindingRoad']
>>> ['The', 'Long', 'AND', 'Winding', 'Road']
2Output:
Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']
9def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
Initial String GeeksForGeeks
Resultant prefix ['Geeks', 'For', 'Geeks']
4Initial String GeeksForGeeks
Resultant prefix ['Geeks', 'For', 'Geeks']
5 Initial String GeeksForGeeks
Resultant prefix ['Geeks', 'For', 'Geeks']
6Initial String GeeksForGeeks
Resultant prefix ['Geeks', 'For', 'Geeks']
7 Initial String GeeksForGeeks
Resultant prefix ['Geeks', 'For', 'Geeks']
8__
Python3
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
2def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
4def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
5 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
6def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
7def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
8def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
09def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
11Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']5
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
13Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']7
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
15
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
16Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']1
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
18def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
19def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
09Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']4
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
23Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']4
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
25def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
16def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
27def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
28def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
19def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
09Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']4
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
25def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
34def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
36def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
23def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
38def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
39def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
5def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
6print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
9def splitAtUpperCase[s]:
for i in range[len[s]-1][::-1]:
if s[i].isupper[] and s[i+1].islower[]:
s = s[:i]+' '+s[i:]
if s[i].isupper[] and s[i-1].islower[]:
s = s[:i]+' '+s[i:]
return s.split[]
splitAtUpperCase['TheLongANDWindingRoad']
>>> ['The', 'Long', 'AND', 'Winding', 'Road']
0def splitAtUpperCase[s]:
for i in range[len[s]-1][::-1]:
if s[i].isupper[] and s[i+1].islower[]:
s = s[:i]+' '+s[i:]
if s[i].isupper[] and s[i-1].islower[]:
s = s[:i]+' '+s[i:]
return s.split[]
splitAtUpperCase['TheLongANDWindingRoad']
>>> ['The', 'Long', 'AND', 'Winding', 'Road']
1def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
45Đầu ra
Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']
Cải thiện bài viết
Python3
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
2def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
4def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
5 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
6def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
7def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
8def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
09def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
11Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']5
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
13Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']7
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
15def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
16Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']1
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
13Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']7
print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
20def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
19def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
09Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']4
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
23Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']4
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
25def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
16def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
27def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
28def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
19def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
09Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']4
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
25def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
34def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
36def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
23def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
38def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
39def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
5def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
6print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
9def splitAtUpperCase[s]:
for i in range[len[s]-1][::-1]:
if s[i].isupper[] and s[i+1].islower[]:
s = s[:i]+' '+s[i:]
if s[i].isupper[] and s[i-1].islower[]:
s = s[:i]+' '+s[i:]
return s.split[]
splitAtUpperCase['TheLongANDWindingRoad']
>>> ['The', 'Long', 'AND', 'Winding', 'Road']
0def splitAtUpperCase[s]:
for i in range[len[s]-1][::-1]:
if s[i].isupper[] and s[i+1].islower[]:
s = s[:i]+' '+s[i:]
if s[i].isupper[] and s[i-1].islower[]:
s = s[:i]+' '+s[i:]
return s.split[]
splitAtUpperCase['TheLongANDWindingRoad']
>>> ['The', 'Long', 'AND', 'Winding', 'Road']
1def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
45Đầu ra
Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']
Cải thiện bài viết
Python3
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
2def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
4def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
5 def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
6def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
7def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
8print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
06def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
08def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
09def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
11Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']5
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
13Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']7
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
15def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
16Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']1
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
13Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']7
print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
20def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
19def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
09Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']4
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
23Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']4
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
25def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
16def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
27def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
28def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
19def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
09Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']4
def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
25def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
34def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
3def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
36def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
23def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
38def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
39def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
5def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
6print[splitAtUpperCase['TheLongAndWindingRoad']]
>>>['The', 'Long', 'A', 'N', 'D', 'Winding', 'Road']
9def splitAtUpperCase[s]:
for i in range[len[s]-1][::-1]:
if s[i].isupper[] and s[i+1].islower[]:
s = s[:i]+' '+s[i:]
if s[i].isupper[] and s[i-1].islower[]:
s = s[:i]+' '+s[i:]
return s.split[]
splitAtUpperCase['TheLongANDWindingRoad']
>>> ['The', 'Long', 'AND', 'Winding', 'Road']
0def splitAtUpperCase[s]:
for i in range[len[s]-1][::-1]:
if s[i].isupper[] and s[i+1].islower[]:
s = s[:i]+' '+s[i:]
if s[i].isupper[] and s[i-1].islower[]:
s = s[:i]+' '+s[i:]
return s.split[]
splitAtUpperCase['TheLongANDWindingRoad']
>>> ['The', 'Long', 'AND', 'Winding', 'Road']
1def splitAtUpperCase[text]:
result = ""
for char in text:
if char.isupper[]:
result += " " + char
else:
result += char
return result.split[]
45Đầu ra
Initial String GeeksForGeeks Resultant prefix ['Geeks', 'For', 'Geeks']