#!/usr/local/bin/python3

# syntax.py by Bill Weinman [http://bw.org/]
# This is an exercise file from Python 3 Essential Training on lynda.com
# Copyright 2010 The BearHeart Group, LLC

class Decoder:
    # In a class method, always list self as first parameter
    def __init__(self):
        print("init")

    def decode(self, aString, aCipher):

        aString = aString.lower()

        decodedString = ''
        for aChar in aString:
           decodedString = decodedString + aCipher[aChar]
        return decodedString

    
def main():

    decoder = Decoder(); 

    clue1 = "Jp wqfht ups csij bqqz jmq zrstfqn xkohtf tpnjmlknai"
    clue2 = "Zfxjx vjx v rdanxj qb nvoo nxvjmrpt mrtmex zfx Mtmt"
    clue3 = "Grb yfqq ytfzdmxj wfm fqrfsj yt ctfze dmjdet, ykg sbk mtte gb ctfz gcztt yfqq ytfzdmxj du sbk rfmg gb hzbxztjj"

    cipher1 = {' ': ' ',
              'a': '_',
              'b': '_',
              'c': '_',
              'd': '_',
              'e': '_',
              'f': '_',
              'g': '_',
              'h': '_',
              'i': '_',
              'j': '_',
              'k': '_',
              'l': '_',
              'm': '_',
              'n': '_',
              'o': '_',
              'p': '_',
              'q': '_',
              'r': '_',
              's': '_',
              't': '_',
              'u': '_',
              'v': '_',
              'w': '_',
              'x': '_',
              'y': '_',
              'z': '_' }

    cipher2 = {' ': ' ',
              'a': '_',
              'b': '_',
              'c': '_',
              'd': '_',
              'e': '_',
              'f': '_',
              'g': '_',
              'h': '_',
              'i': '_',
              'j': '_',
              'k': '_',
              'l': '_',
              'm': '_',
              'n': '_',
              'o': '_',
              'p': '_',
              'q': '_',
              'r': '_',
              's': '_',
              't': '_',
              'u': '_',
              'v': '_',
              'w': '_',
              'x': '_',
              'y': '_',
              'z': '_' }

    decodedString = decoder.decode(clue2, cipher2)

    print(clue2)
    print(decodedString)

if __name__ == "__main__": main()


@@ -524,16 +524,264 @@
 String%0A%0A
+    # inserts spaces in string to visually separate underscore characters%0A    def spacedString(self, aString):%0A        spacedString = ''%0A        for aChar in aString:%0A           spacedString = spacedString + aChar + ' '%0A        return spacedString%0A
     %0Adef
@@ -2444,14 +2444,36 @@
 int(
+decoder.spacedString(
 clue2)
+)
 %0A   
@@ -2485,23 +2485,45 @@
 t(decode
-dString
+r.spacedString(decodedString)
 )%0A%0Aif __

Add method spacedString.