Changed while loops to for loops with ranges
Deleted the moodle code that was originally used.