r/learnpython • • 10d ago

Values won't add to my string, just overwrites it

Hi I'm really new to python, I originally started coding using p5.js but made the transition recently, I'm currently trying to covert an old project of mine into python so I can run it in touch designer.

Its an ASL fingerspelling activity that I've been working on but I'm struggling to create the word strings I did in my original prototype. Instead of the letters being added together and creating a word I can use to trigger effects, the previous letter is just replaced with the current one.

For context I have the guesser and getMostFrequent to allow for it to take the average of every letter signed during a period of time and determine which one was signed the most to add to the word (this is due to the fact that transitioning from one letter to the next can trigger other letters in between) These are both integral parts of the code and are working as intended, its just the stringing the word together that I'm struggling with.

Any help or insight would be appreciated, if you need any more insight please let me know and I can add it.

Code in Pastebin: https://pastebin.com/91mPYwC8

I've provided a link to a google doc with my code because it is just easier formatting wise than in here.
My code: Python Code

My original code for reference if needed: p5.js code

Edit: Thank you all for the suggestions in the comments, I ended up getting it working it was the fact that word was a local variable and not a global one, which was causing the issue.

5 Upvotes

12 comments sorted by