Skip to content

Feat/ye olde emoticons python solution -> main#26

Open
alangnt wants to merge 2 commits intocodedex-io:mainfrom
alangnt:feat/ye-olde-emoticons-python-solution
Open

Feat/ye olde emoticons python solution -> main#26
alangnt wants to merge 2 commits intocodedex-io:mainfrom
alangnt:feat/ye-olde-emoticons-python-solution

Conversation

@alangnt
Copy link
Copy Markdown
Contributor

@alangnt alangnt commented Mar 30, 2026

Hi Codédex team,

This PR creates a folder for today's Ye Olde Emoticons 📰 challenge, adds a working Python solution, and updates the README.md file to add today's GitHub link.

Here's the code :

def emoticons_mood(message):
  # first let's define the emoticons
  happy_emoticons = [":)", ":p", "xd", ":3", "<3", "\\m/"]
  sad_emoticons = [":'(", ":(", "t(-.-t)"]

  # we init the score
  score = 0

  # now we calculate
  for emoticon in sad_emoticons:
    score -= message.lower().count(emoticon)
  for emoticon in happy_emoticons:
    score += message.lower().count(emoticon)

  # then we return the score
  return score

Here's how it works :

  • first we define two arrays containing the happy and sad emoticons
  • then we init a score at 0
  • now for each emoticon in the sad emoticons array we remove 1 to score for each sad emoticon
  • then we do the same for the happy emoticons except this time we add 1 for each
  • finally we return the score

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant