I have seen posts about this but they all have something to do with `while (x) == True:` 

my function has none of this. These are in 2 separate files. Please help!
[Screenshot of pycharm](https://i.stack.imgur.com/aXq7t.png)

I know that it is a lot of code, but I have spent a few hours on this, and I really can't figure out why this is happening. I am hoping that posting this project in entirety, I can have the function print in a window. At this point, it does not even need to be a tkinter GUI, if you have any other GUI that you think might work, please, let me know. Thank you in advance.

**CODE**

```
import random

moves = ["RU", "RD", "LD", "LU", "BL", "BR", "DR", "DL", "FL", "FR", "UL", "UR"]
dir = ["", "2"]
slen = random.randint(25, 30)

def scramble_gen():
    scramble = [0] * slen
    for x in range(len(scramble)):
        scramble[x] = [0] * 2
    return scramble

def scramble_replace(ar):
    for x in range(len(ar)):
        ar[x][0] = random.choice(moves)
        ar[x][1] = random.choice(dir)
    return ar

def valid(ar):
    for x in range(1, len(ar)):
        while ar[x][0] == ar[x-1][0]:
            ar[x][0] = random.choice(moves)
    for x in range(2, len(ar)):
        while ar[x][0] == ar[x-2][0] or ar[x][0] == ar[x-1][0]:
            ar[x][0] = random.choice(moves)
    return ar

def sprint(ar):
    for x in range(len(ar)):
        print(str(ar[x][0]) + str(ar[x][1]), end= " ")

s = scramble_replace(scramble_gen())'''

```

**NEW FILE**

```
from tkinter import *
import random
from scrambler import *
window = Tk()
window.title("Bryson's Scrambler")
lbl = Label(window, text = sprint(valid(s)))
lbl.grid(column=0, row=0)

txt = Entry(window,width=10)

txt.grid(column=1, row=0)

def clicked():

    lbl.configure(text="Button was clicked !!")

btn = Button(window, text="Click Me", command=clicked)

btn.grid(column=2, row=0)

window.mainloop()

window.mainloop()

```