String array with repeating characters python -
i'm trying break sentence characters such as: "the boy good", , place in sentence of each letter, each time letter 'o', place stays same both of letters. how can separate 2 same letters?
with open("d:\users\hazembazem\desktop\python random\crap\encrypt.txt", "rb") f: file= f.read() print file file= list(file) item in file: a=file.index(item) print (a)
the file txt file containing: "the boy good".
a meant place of character, it's instead shows me this:
0 1 2 3 4 5 6 3 8 9 10 3 12 5 5 15
string.index(s, sub[, start[, end]])
like
find()
raisevalueerror
when substring not found.
string.find(s, sub[, start[, end]])
return lowest index in
s
substringsub
found...
so, yeah, isn't want.
check out
with open("filename") f: string = f.read() print range(len(string)) i,c in enumerate(string): print i,c
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] 0 t 1 h 2 e 3 4 b 5 o 6 y 7 8 w 9 10 s 11 12 g 13 o 14 o 15 d
Comments
Post a Comment