I want to add “…” after every odd index in my list (or after every second word), but I can’t quite figure out how to do it.
Advertisement
Answer
you can use something like that:
sentence = input().split() ans = [] for i in range(len(sentence)): if i%2: ans.append(sentence[i]+'...') else: ans.append(sentence[i]) print(' '.join(ans))