A good clue to the answer "Is this code correct", when applied to a homework assignment like this is if you get something that makes any possible sense as a word, then you were probably correct. Conversely, if you get a string of random crap characters out the end, then your code is probably incorrect.
If you don't accept that argument, suppose I were to create a homework problem that has some intelligent sentence as the "correct" result. However, imagine that as the problem designer, I want to predict which errors you may make, and as a result, return other creatively wrong answers, each of which makes sense as a phrase? Now that is a difficult problem to solve - pretty tough to do. Possible I am sure, but a difficult thing, since I would need to carefully craft something that gives just the carefully designed wrong answer if you make what I think is the mistakes I expect you to make. This is way harder to do than you think, and a lot of work invested to just confuse some poor schlepp of a student, who may not actually make the exact mistakes you designed into the problem. Now, try building a variety of such Easter eggs into a simple problem like this, predicting which errors you might logically make? Worse, suppose I did exactly that? Now my students would never know how to trust their own results, not knowing if they had stumbled into one of the Easter egg traps my instructor had laid.
Seriously, the above is an actively bad way to design a homework problem, with a lot of work invested to not actually help the student. Homework should be designed to guide a student to learn, not to leave them totally confused. As I said, you design a homework problem to help a student to learn. A good problem should have a result that is some meaningful phrase.
But, just suppose you have a homework problem designer with a slightly devious bent of mind? They might create a problem where the intended result might be the actual phrase "This is random crap", just to test the self-confidence of my students to trust their own work. Of course, any other solution made in error will yield nothing readable. I'm not saying your instructor did not do the same, but look deeply into his or her soul. Is that person the devious sort? Could they be testing you?