The most likely explanation for Alejandro's program not working after copying and pasting code is: There was an error in the original code.
While issues related to format or the specific tools might cause problems, the first and most common reason for a copied code snippet to fail is that the snippet itself contains errors.