📅  最后修改于: 2022-03-11 14:45:47.806000             🧑  作者: Mango
var = ' this is a test '
word_counter = 0
start_status = True
for i in range(len(var)):
if var[i] != ' ':
if start_status == True:
word_counter = word_counter + 1
start_status = False
if var[i]==' ':
start_status = True
print(word_counter)