Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Create strikethrough / strikeout / overstrike string type

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 being a striked out version of the original string. Like this..

Something like.

def strike(text):
    i = 0
    new_text = ''
    while i < len(text):
        new_text = new_text + (text[i] + u'\u0336')
        i = i + 1
    return(new_text)

So far I've only been able to concatenate rather than combine.

like image 601
I_do_python Avatar asked Aug 11 '14 13:08

I_do_python


1 Answers

def strike(text):
    result = ''
    for c in text:
        result = result + c + '\u0336'
    return result

Cool effect.

like image 113
pdw Avatar answered Oct 07 '22 17:10

pdw