import random
x = 0
y = 0
nights = 0
turn = 0
turns = []

while (nights < 10):
    step = random.randrange(4)
    if step == 0:
        x = x+1
    if step == 1:
        x = x-1
    if step == 2:
        y = y+1
    if step == 3:
        y = y-1
    
    turn = turn + 1
    
    if x == 0 and y == 0:
        nights = nights + 1
        print("The Man Has Made It Home After ", turn, "Turns")
        turns.append(turn)
        turn = 0
    if turn/1000 % 1000 == 0:
        print("(", x,y, ")")

average = sum(turns) / len(turns)
print(average)
The Man Has Made It Home After  60 Turns
( 0 0 )
The Man Has Made It Home After  10 Turns
( 0 0 )
The Man Has Made It Home After  20050 Turns
( 0 0 )
The Man Has Made It Home After  6 Turns
( 0 0 )
The Man Has Made It Home After  520 Turns
( 0 0 )
The Man Has Made It Home After  4 Turns
( 0 0 )
( -348 -654 )
( 139 -831 )
( 89 -525 )
( 934 -766 )
( 1816 -70 )
( 2433 -731 )
( 2749 -1491 )
( 1765 -2059 )
( 3076 -1474 )
( 3741 -1243 )
( 3574 -2110 )
( 4781 -4095 )
( 4793 -5299 )
( 6508 -4748 )
( 6345 -3445 )
( 5805 -3109 )
( 5817 -3751 )
( 5311 -3397 )
( 6590 -3096 )
( 6541 -2791 )
( 6467 -2601 )
( 6827 -2609 )
( 6307 -1901 )
( 5755 -2407 )
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
/home/dreamerblock/L/_notebooks/Drunk_Man.ipynb Cell 1 in <cell line: 8>()
      <a href='vscode-notebook-cell://wsl%2Bubuntu/home/dreamerblock/L/_notebooks/Drunk_Man.ipynb#W0sdnNjb2RlLXJlbW90ZQ%3D%3D?line=5'>6</a> turns = []
      <a href='vscode-notebook-cell://wsl%2Bubuntu/home/dreamerblock/L/_notebooks/Drunk_Man.ipynb#W0sdnNjb2RlLXJlbW90ZQ%3D%3D?line=7'>8</a> while (nights < 10):
----> <a href='vscode-notebook-cell://wsl%2Bubuntu/home/dreamerblock/L/_notebooks/Drunk_Man.ipynb#W0sdnNjb2RlLXJlbW90ZQ%3D%3D?line=8'>9</a>     step = random.randrange(4)
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/dreamerblock/L/_notebooks/Drunk_Man.ipynb#W0sdnNjb2RlLXJlbW90ZQ%3D%3D?line=9'>10</a>     if step == 0:
     <a href='vscode-notebook-cell://wsl%2Bubuntu/home/dreamerblock/L/_notebooks/Drunk_Man.ipynb#W0sdnNjb2RlLXJlbW90ZQ%3D%3D?line=10'>11</a>         x = x+1

File ~/anaconda3/lib/python3.9/random.py:305, in Random.randrange(self, start, stop, step)
    303 if stop is None:
    304     if istart > 0:
--> 305         return self._randbelow(istart)
    306     raise ValueError("empty range for randrange()")
    308 # stop argument supplied.

KeyboardInterrupt: