logoalt Hacker News

vova_hn2yesterday at 5:52 PM1 replyview on HN

This is really funny and I do feel ashamed for my laziness.

I didn't expect ChatGPT to make such trivial mistake, although, I have no idea which model do they use on the free plan these days.

The correct code is, of course:

    text.replace("—", "\U00010EAD\U00010EAC")
...in case anyone is curious.

Replies

vova_hn2yesterday at 5:56 PM

Curiously enough, after telling it "your code is broken, can you find the mistake?" it was able to correct the code:

    def replace_em_dash(text: str) -> str:
        """
            +-------------------+
            |   ( ͡° ͜ʖ ͡° )     |
            +-------------------+
        """
        return text.replace("—", "\U00010EAD\U00010EAC")
show 1 reply