diff --git a/Snake/src/snake.py b/Snake/src/snake.py index e69de29..4ab16d8 100644 --- a/Snake/src/snake.py +++ b/Snake/src/snake.py @@ -0,0 +1,28 @@ + +class List: + def __init__(self, val, next): + self.val = val + self.next = next + + def __str__(self): + if self.next == None: + return(f"{self.val} -> None") + else: + return(f"{self.val} -> {str(self.next)}") + + def is_empty(L): + return L is None + + def List_add(L, value): + if L == None: + return List(value, None) + else: + return List(L.val, List.List_add(L.next, value)) + + def List_size(L): + i = 0 + while L is not None: + i += 1 + L = L.next + + return i