Skip to content

Instantly share code, notes, and snippets.

@albertstartup
Created December 15, 2016 19:54
Show Gist options
  • Save albertstartup/3099dbed2403486dad832308c9e27539 to your computer and use it in GitHub Desktop.
Save albertstartup/3099dbed2403486dad832308c9e27539 to your computer and use it in GitHub Desktop.
make shift matrix using list comprehension
def makeshiftmatrix(upper_or_lower, row, column):
return [[1 if item_idx == row_idx+upper_or_lower else 0 for item_idx in range(0, column)] for row_idx in range(0, row)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment