Yes, shortening code by reducing redundancy is within the scope of Code Review — it naturally falls under the category of general code improvements.
However, migrating a question involves a more complex decision-making process than you described. Please read A guide to Code Review for Stack Overflow users for more information.
For the specific question you cited, the Stack Overflow moderator may have declined to migrate the question based on…
- Lack of evidence that the question is off-topic for Stack Overflow. Did you cite an off-topic reason in your flag? (The moderator dismissed your flag without closing the question as off-topic, so it can be deduced that the moderator thinks it's on-topic for Stack Overflow.)
- Poor question quality (the "Don't Migrate Crap" rule). The question basically consists of a code dump with no explanation of motivation. What is
a? What doeslength_wordlistmean, and are there just two cases or is this an excerpt of 2 out of n cases? The code looks like it might be incomplete, since the first case hasFILE.close()but the second case does not. - A comment by @jonrsharpe (a highly ranked Code Review member) encouraging the original author to cross-post with clarifications. If @jonrsharpe had thought that the question was worthy of migration, he would likely have flagged it instead.