Skip to content
Advertisement

How do you scan characters in multi-character multi-string arrays in Python?

I’m working on my first Python project for a device that reads a string from OCR and outputs braille. The braille device can only output 6 letters at a time. I’m stuck trying to scan each character in the 6 character long multi-string array.

For simplicity’s sake, for now I only want to print “this is (insert character)” for every character in the multi-string array. In reality, the output would be to run the code that tells the first two motors to create the character in braille, and then do it for the remaining 5 characters with the 10 remaining motors with a short delay between each 6 character long string. How do I scan each 6 character long string and loop it for the rest of the strings in the array?

Here’s where I’m at so far:

JavaScript

Advertisement

Answer

A dictionary should do the trick:

JavaScript

Once you’ve built your punctuation dict with all the items you need, the loop will either get the corresponding value from it, or default to the actual char.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement