Ad
  • Default User Avatar

    Your while statement isnt behaving as you think. As soon as it enters the while loop it returns 's'. The code following it never executes. return breaks any loop or code execution and will return the value, in this case 's'. It always returns the first three elements because you return the first three elements before any operation in conducted. Furthermore, you should consider completing operations on the list and not loading it into separate variables(n1, n2 n3). From a memory standpoint this is inefficient and IMO is messier than just completing operations on the list itself. These operations can be done on the passed in list itself.