Skip to content

Instantly share code, notes, and snippets.

@keitheis
Last active December 26, 2015 04:39
Show Gist options
  • Save keitheis/7094579 to your computer and use it in GitHub Desktop.
Save keitheis/7094579 to your computer and use it in GitHub Desktop.
仍是個有懈可擊的解。
def part_list(l, head_amount=1, tail_amount=1):
length = len(l)
tail_start = length - tail_amount
return l[head_amount-1], l[head_amount:tail_start], l[tail_start]
def main():
l = range(5)
x, y, z = part_list(l, 1, 1)
print(x) # 0
print(y) # [1, 2, 3]
print(z) # 4
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment