2
def emoji_counter(string):
no_of_emojis = 0
for char in string:
    if char in emoji.UNICODE_EMOJI_ENGLISH:
        no_of_emojis += 1
return no_of_emojis

I have written the above code. It works fine only for some emojis. But for a string like this "Oh, come on!!‍♂️" ( I am analyzing a whatsapp text )

The output for emoji_counter function is 4

When I copied the string to the one of the cells in my Jupyter Notebook, it shows extra two characters (a red dot and a gender symbol next to it). How can I fix this?

Thanks

1 Answers1

0

Your code works fine. The reason you are getting wrong count is because, how the emojis are setup. Some of the emoji's are combination of emoji's

In your case ‍♂️ is actually shown as this in Jupyter notebook"

I have checked other emoji's also. Mostly the one that has a gender associated with it comes out like this.

Let me know if this helps.

DDJ
  • 5
  • 4