Commit 87f1523d authored by Mark Tearle's avatar Mark Tearle
Browse files

Alter display code to pad with spaces and simplify

parent 4fa88583
......@@ -160,9 +160,9 @@ class VendingMachine:
return (code == '501', code, string)
def display(self, string):
if len(string) > 10:
string = string[0:10]
self.wfh.write('D'+string+'\n')
# display first ten characters of string, left aligned
self.wfh.write('D%-10.10s\n' % string)
(code, string) = self.get_response()
return (code == '300', code, string)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment