myStr = "myStringInPython"
iCount = 0
pos = []
pos.append(0) #char index 0
for i in myStr:
if i == i.upper():
iCount = iCount+1
pos.append(myStr.index(i))
pos.append(len(myStr)) #char index = last index
print("there are " + str(iCount+1) + " words")
print(pos)
words = []
for j in pos:
if pos.index(j)>0:
words.append(myStr[pos[pos.index(j)-1]:j])
print(words)
Nessun commento:
Posta un commento