Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.6 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
68f6587287ad1f4ad39b0c7c Challenge 90: Character Limit 29 challenge-90

--description--

In this challenge, you are given a string and need to determine if it fits in a social media post. Return the following strings based on the rules given:

  • "short post" if it fits within a 40-character limit.
  • "long post" if it's greater than 40 characters and fits within an 80-character limit.
  • "invalid post" if it's too long to fit within either limit.

--hints--

can_post("Hello world") should return "short post".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(can_post("Hello world"), "short post")`)
}})

can_post("This is a longer message but still under eighty characters.") should return "long post".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(can_post("This is a longer message but still under eighty characters."), "long post")`)
}})

can_post("This message is too long to fit into either of the character limits for a social media post.") should return "invalid post".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(can_post("This message is too long to fit into either of the character limits for a social media post."), "invalid post")`)
}})

--seed--

--seed-contents--

def can_post(message):

    return message

--solutions--

def can_post(message):
    if len(message) <= 40:
        return "short post"
    elif len(message) <= 80:
        return "long post"
    else:
        return "invalid post"