Take Altklausur 17 and compare your solution. From the course Einführung in die Programmierung at Ludwig-Maximilians-Universität München (LMU).