import sys
N=int(sys.stdin.readline().strip());
def produre_word(word):
output_word=[];
for seek_char in word:
o_len=len(output_word);
if(o_len>1and seek_char==output_word[o_len-1] and output_word[o_len-2]==seek_char):
continue;
else:
if(o_len>2and seek_char==output_word[o_len-1] and output_word[o_len-2]==output_word[o_len-3]):
continue;
output_word.append(seek_char)
return''.join(output_word)
fori in range(0,N):
word=sys.stdin.readline().strip()
print(produre_word(word))
关键是两个单词变量,一个是原单词word变量,一个重新输出单词变量output_word。可以想象自己正output_word中一个一个的输入字符。每次输入前,都看看条件,是拼写错的,就跳过。对的才输入。