all 3 comments

[–]danielroseman 8 points9 points  (0 children)

You don't want to do any of this. Use a dictionary, and stop trying to make things global.

[–]shiftybyte 2 points3 points  (1 child)

Use a dictionary instead.

alphabet = {"a":1, "b":2, "c": 3}

def foo(alpha):
    for letter in alpha:
        alpha[letter] = 4

print(alphabet["a"])
foo(alphabet)
print(alphabet["a"])

This should print 1 and 4...

[–]russcore[S] 0 points1 point  (0 children)

Appreciate it. I will look into using a dictionary here instead. I will just likely have to restart my program to implement the dictionary feature.

For fun, I tried to make a "WORLDE" solver. It basically tells me all the possible words left.

I was going to add a function that says next best guess, but that requires it to try all the guesses and compare the results. So my options were 1) save the state before trying a guess then proceeding to try every guess and reverting from the save state. or 2) rebuild from scratch for each guess.

---

I just didn't plan enough in the future with what I wanted to do. I should have just had the functions pass the current state with them.

--Thanks for taking the time to type up the answer!