Dear Student,
There is no problem with the code given in the handouts. But since you may be using copy/paste method to run the programs then you may face errors in your copied code. I suggest you to practice the code by writing it yourself instead of copying from the handouts.