added list slicing and while loop versions
added version using list slicing