Skip to content

Instantly share code, notes, and snippets.

@IEdiong
Last active May 21, 2021 09:24
Show Gist options
  • Save IEdiong/e9c7aadd3fb2565343c4942c32d83e94 to your computer and use it in GitHub Desktop.
Save IEdiong/e9c7aadd3fb2565343c4942c32d83e94 to your computer and use it in GitHub Desktop.
Algorithm Fridays Week 6
from collections import deque
def shuffleClass(listOfPupils, n):
#test if listOfPupils is a list, has none value or empty
if (not isinstance(listOfPupils, list)) or (not listOfPupils):
return []
#takes the last 'n' items to the front using 'deque'
else:
listOfPupils = deque(listOfPupils)
listOfPupils.rotate(n)
return list(listOfPupils)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment