0

Python index

so my goal is, to index each space in a list. like this: empt = [] name = ["kevin", " ", "python", " ", "is match"] for abc in range(len(name)): empt.append(name.index(" ")) print(empt) but the result become [1, 1, 1, 1] i want like this [1, 3] any idea?

2nd Sep 2017, 1:46 AM
Kevin AS
Kevin AS - avatar
1 Respuesta
+ 5
empt = [] name = ["kevin"," ","python"," ","ismatch"] for i in range(len(name)): if name[i] == " ": empt.append(i) print(empt) I don't know what you're trying to do but puting spaces into arrays like that doesn't seem to be a good idea.
2nd Sep 2017, 1:55 AM
Dapper Mink
Dapper Mink - avatar