나는 낙타의 경우 문자열을 별도의 단어로 변환하고이를 목록에 추가하는 데 어려움을 겪고 있습니다. 거의 코드를 완성하지만 IndexError : string 인덱스가 범위를 벗어납니다. 누구든지이 도움을 줄 수 있습니까 ?? 출력은 실행이있을 때 :이이 작업을 달성하는 내 방식이다indexerror for 루프 문제
['This']
['This', 'Is']
['This', 'Is', 'A']
['This', 'Is', 'A', 'Camel']
['This', 'Is', 'A', 'Camel', 'Case']
Traceback (most recent call last):
for i in string[char]:
IndexError: string index out of range
List = []
string = "ThisIsACamelCaseString"
newstring = ""
count = 0
char = 0
null = 0
for i in string[char:]:
if i == i.upper():
newstring = newstring + i
count += 1
char += 1
for i in string[char]: **< error here**
if i == i.upper() and char == 1:
null += 1
elif i == i.lower():
newstring = newstring + i
char += 1
count += 1
elif i == i.upper() and count > 0:
List.append(newstring)
print(List)
newstring = ""
break
는 전체 문자열을 출력하지만이 시트에 구멍을 통해보고 병을 진단하는 것을 시도 의사처럼 실제 문자열 –
에서 마지막 단어 "문자열". –
게시물에 수정 사항을 추가하고 사진과 반대되는 코드로 업데이트하는 것이 좋습니다. – GedAWizardofEarthSea