Quote:I am just pointing the error. I even didn't read the rest of the code.
The OP is just getting started using functions and you taught him the exact wrong thing to do. You should consider that. When shown my answer and yours he picked the one that he thinks is easiest which is not going to do him any favors in the future.
This is like teaching someone to just exec a string when building a calculator.
Yes it works. It is still wrong and not at all helpful.