Last active
May 21, 2021 09:24
-
-
Save IEdiong/e9c7aadd3fb2565343c4942c32d83e94 to your computer and use it in GitHub Desktop.
Algorithm Fridays Week 6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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