I would appreciate some help in creating a function that iterates through a string and combines each character with a strikethrough character (\\u0336). With the output bein
How about:
from itertools import repeat, chain
''.join(chain.from_iterable(zip(text, repeat('\u0336'))))
or even more simply,
'\u0336'.join(text) + '\u0336'
Edited
As pointed out by roippi other answers so far are actually correct, and this one below is wrong. Leaving it here in case others get the same wrong idea that I did.
Other answers so far are wrong - they do not strike out the first character of the string. Try this instead:
def strike(text):
return ''.join([u'\u0336{}'.format(c) for c in text])
>>> print(strike('this should do the trick'))
'̶t̶h̶i̶s̶ ̶s̶h̶o̶u̶l̶d̶ ̶d̶o̶ ̶t̶h̶e̶ ̶t̶r̶i̶c̶k'
This will work in Python 2 and Python 3.
def strike(text):
result = ''
for c in text:
result = result + c + '\u0336'
return result
Cool effect.