curriculum/challenges/english/blocks/daily-coding-challenges-python/68f6587287ad1f4ad39b0c7c.md
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.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")`)
}})
def can_post(message):
return message
def can_post(message):
if len(message) <= 40:
return "short post"
elif len(message) <= 80:
return "long post"
else:
return "invalid post"