I have written the turtle graphics functions that define the fourteen segments, and the functions that assemble these segments to form characters, e.g.
def MethodA (width) :
top_stroke(width)
middle_stroke(width)
left_stroke
right_stroke(width)
I have all the definitions ready, but how do I let python to read an input and convert the characters of the input into the fourteen segments forms, which I defined previously?
Idealy, if I enter “Pizza”, the program should produce the output of the characters ‘PIZZA’ in the fourteen-segments form.
Any suggestions are welcomed and appreciated. Thanks,
You could define a dictionary with function references like this:
Then, for a string
s:This code works using
Characters[c]to look up the function reference in the dictionary, then the(width)causes the function to be called (with awidthparameter, as the function expects).