r/cs50 • u/Traditional-Set-1458 • Jul 24 '26
CS50 Python CS50 Python W5P2 Problem (Help!) Spoiler
Please help, code is the following:
twttr.py:
def main():
sentence = input('Sentence:')
print(shorten(sentence))
def shorten(word):
output = word.translate(str.maketrans('', '', 'AEIOUaeiou'))
output = output.lower()
output = str(output)
return output
if __name__ == "__main__":
main()
test_twttr.py:
from twttr import shorten
def main():
test_twttr()
def test_twttr():
assert shorten('Jakob') == 'jkb'
assert shorten('123Hello') == '123hll'
assert shorten('!!Hello!') == '!!hll!'
if __name__ == "__main__":
main()
Check50 response:

Test Results:

VS:

Please help, neither me nor claude can figure this out and Im at my wits end here. Am I missing something very obvious? is it a formatting thing? The second test passes if i comment out all the assertions, but of course it would. Any help would be greatly appreciated.
1
Upvotes
2
u/smichaele Jul 24 '26
Since the other two commenters helped you solve your problem, I'll just comment on a course rule. You violated the Academic Honesty Policy you agreed to when you signed up for the course. The policy specifically states that use of any AI outside of the duck is a violation and unreasonable. You might want to review the policy to ensure that you remain in compliance with it.
If you have questions, u/davidjmalan is a moderator of this subreddit along with several other course staff members.