Morse code to text, stuck


#1

class Morse(object):
    morse_d = {'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': '--..', '1': '.----', '2': '..---', '3': '...--', '4': '....-',
               '5': '.....', '6': '-....', '7': '--...', '8': '---..', '9': '----.',
               '0': '-----', '.': '.-.-.-', ',': '--..--', "'": '.----.', '"': '.-..-.',
               '_': '..--.-', ':': '---...', ';': '-.-.-.', '?': '..--..', '!': '-.-.--',
               '-': '-....-', '+': '.-.-.', '/': '-..-.', '(': '-.--.', ')': '-.--.-',
               '=': '-...-', '@': '.--.-.', ' ': ' '}

    def to_morse(self, message):
        output = str()
        for letter in message:
            if letter.upper() in self.morse_d:
                output += self.morse_d[letter.upper()]
            else:
                print('There is no symbol like that!')
        return output

    def get_input(self):
        inp = input("Everything that you will type here will be translated to Morse Code. ")
        return inp

    def interaction(self):
        while True:
            inp = self.get_input()
            if len(inp) > 0:
                print(self.to_morse(inp))
            else:
                break

class Characters(object):
    characters_d = {'.-': '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', '.----': 1, '..---':
                    '2', '...--': '3', '....-': '4', '.....': '5',  '-....': '6', '--...': '7', '---...':
                    '8', '----.': '9', '0': '-----', '.': '.-.-.-' , ',': '--..--', "'": '.----.', '"':
                    '.-..-.', '_': '..--.-', ':': '---...', ';': '-.-.-.', '?': '..--..', '!': '-.-.--',
                    '-': '-....-', '+': '.-.-.', '-..-.': '/', '-.--.': '(', '-.--.-': ')', '-...-': '=',
                    '.--.-.': '@', ' ': ' '}

#for some reason when i added E(without '.' in characters_d) (same with '-' and 'T')
# to the characters_d it shows errors, probably because it only contains dot
#i do not really know how to fix it to be honest
#also i do not know how to make it work properly if '.' is as itself and as 'E' too, kinda hard for me

    def from_morse(self, msg):
        output_0 = str()
        for symbols in msg:
            if symbols in self.characters_d:
                output_0 += self.characters_d #I do not really know how to make it replace the symbols ., - with letters
            else:
                print('There is no symbol like that!')
        return output_0
    #if this function and E/. + -/T will work then the rest will be alright, program will be working i guess
    #i was writing it without access to the internet so it was kinda hard
    #i only had my knowledge, which is very limited

    def get_input0(self):
        text = input("Everything that you will type here will be translated to alphabet from Morse Code. ")
        return text

    def interaction(self):
        while True:
            text = self.get_input0()
            if len(text) > 0:
                print(self.from_morse(text))
            else:
                break

    def determine(self):
        choice = input("What do you want? Translator from alphabet to Morse Code, or from Morse Code to alphabet?"
                       " Type 1 or 2. ")
        if choice == "1":
            morse = Morse()
            morse.interaction()
        elif choice == "2":
            alphabet = Characters()
            alphabet.interaction()

alphabet = Characters()
alphabet.determine()

#please do not write code for me, just try to make me understand and learn something, tell me what is wrong,
#and what i should look up, and then i will try my best to make it happen
#i think it can be written much shorter too but whatever

So basically I created a topic:

and I had some problems with it and I wanted to continue the topic because I wanted to add something new to the program but I am stuck now and I can't find any solution on the internet so it's kinda hard for me, I am a big newbie when it comes to programming, I only finished the basic course on codecademy, that's all. Please don't post like full code because I don't think I will learn anything from it. Basically I want it to work in the morse-text way too, tried to do it without internet connection (because I haven't had any in past 7 days, thats why the topic got closed, so i can't write in it now :/) but I got stuck and didn't have enough knowledge to know what to do. Any help/advice/comment will be greatly appreciated, i've already put some comments in the code so, that's all, help a noob pls :smiley:


#2

To initialize an empty string, just use,

output = ""

However, you may wish the code output to be comma separated so a list would be the way to go.

output = []

and in the code,

for letter in message.upper():
    if letter in self.morse_d:
        output.append(self.morse_d[letter])
return ", ".join(output)

#3

Umm I don't think you actually helped me... This changes almost nothing, and I don't want it to be comma seperated, I just want it to be translated in both ways - from morse to letters and from letters to morse (this is already working, i only need to write morse to letters). I was trying to search a lot of time for something that would help me but either I find something that doesn't help me or I just don't understand, that's why I've written this topic - because I do not know how to write code for translating morse to letters - I've written it in code by comments what I exactly have problem with and why I need help. Now I realised that I only need to get function from_morse working, nothing else is needed - i noticed that characters_d is a little messy and badly written, I fixed it. Basically what I need is making from_morse function working, everything else is good I think. When I choose method to translate from morse, and I write letters I get msg "there is no symbol like that" and when I try any morse version of something I get error:
"Traceback (most recent call last):
File "C:/Users/Granatnik/Desktop/morse.py", line 80, in
alphabet.determine()
File "C:/Users/Granatnik/Desktop/morse.py", line 77, in determine
alphabet.interaction()
File "C:/Users/Granatnik/Desktop/morse.py", line 65, in interaction
print(self.from_morse(text))
File "C:/Users/Granatnik/Desktop/morse.py", line 51, in from_morse
output_0 += self.characters_d
TypeError: Can't convert 'dict' object to str implicitly

Below is my full code, a little fixed this time and without comments. I just need help with the second method - translating from morse to letters.

class Morse(object):
    morse_d = {'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': '--..', '1': '.----', '2': '..---', '3': '...--', '4': '....-',
               '5': '.....', '6': '-....', '7': '--...', '8': '---..', '9': '----.',
               '0': '-----', '.': '.-.-.-', ',': '--..--', "'": '.----.', '"': '.-..-.',
               '_': '..--.-', ':': '---...', ';': '-.-.-.', '?': '..--..', '!': '-.-.--',
               '-': '-....-', '+': '.-.-.', '/': '-..-.', '(': '-.--.', ')': '-.--.-',
               '=': '-...-', '@': '.--.-.', ' ': ' '}

    def to_morse(self, message):
        output = ""
        for letter in message:
            if letter.upper() in self.morse_d:
                output += self.morse_d[letter.upper()]
            else:
                print('There is no symbol like that!')
        return output

    def get_input(self):
        inp = input("Everything that you will type here will be translated to Morse Code. ")
        return inp

    def interaction(self):
        while True:
            inp = self.get_input()
            if len(inp) > 0:
                print(self.to_morse(inp))
            else:
                break

class Characters(object):
    characters_d = {'.-': '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', '.----': 1, '..---':
                    '2', '...--': '3', '....-': '4', '.....': '5',  '-....': '6', '--...': '7', '---...':
                    '8', '----.': '9', '-----': '0', '.-.-.-': '.', '--..--': ',', ".----.": "'", '.----.':
                    '"', '.-..-.': '_', '..--.-': ':', '-.-.-.': ';', '..--..': '?', '-.-.--': '!',
                    '-....-': '-', '.-.-.': '+', '-..-.': '/', '-.--.': '(', '-.--.-': ')', '-...-': '=',
                    '.--.-.': '@', ' ': ' '}


    def from_morse(self, msg):
        output_0 = ""
        for symbols in msg:
            if symbols in self.characters_d:
                output_0 += self.characters_d
            else:
                print('There is no symbol like that!')
        return output_0


    def get_input0(self):
        text = input("Everything that you will type here will be translated to alphabet from Morse Code. ")
        return text

    def interaction(self):
        while True:
            text = self.get_input0()
            if len(text) > 0:
                print(self.from_morse(text))
            else:
                break

    def determine(self):
        choice = input("What do you want? Translator from alphabet to Morse Code, or from Morse Code to alphabet?"
                       " Type 1 or 2. ")
        if choice == "1":
            morse = Morse()
            morse.interaction()
        elif choice == "2":
            alphabet = Characters()
            alphabet.interaction()

alphabet = Characters()
alphabet.determine()

#4
 self.characters_d[symbol]

#5

It is working only for E and T, probably because E is just "." and T is just "-", even if I wrote for example .- it printed ET. If I delete the E and T from the characters_d then it always prints "There is no symbol like that!" no matter what I type in. I got so lost in this code I no longer know what should I do know to be honest... I'll never get it working, lol...


#6

Switch to Unicode, perhaps?

U+2013 => en dash
U+2014 => em dash
U+00B7 => middot
U+2022 => bullet

>>> a = {'A': '\u2022\u2015'}
>>> a
{'A': '‒―'}
>>>

#7

I don't think it has much sense to switch to unicode - the user will have to copy the symbols, also I tried it only with A, it works if I want to translate from letters to morse, but from morse to letters it doesn't work and this is the only thing I need to get done here.


#8

It's obvious from here what the problem is. Don't put it on us. You have the problem and enough gist to solve it. Do it. And, do share.


#10

The problem was the same from the beginning of the topic, I created this topic because I needed help with this program, I'm just the biggest noob of programming that ever existed and I seek help here, because I am not able to find any solution anywhere so that's why I created this topic. I've spent around 10 hours (this makes me wanna cry) probably looking for solution and trying to fix this code by myself too so I thought "If this isn't a good reason to create a topic, I no longer know what is a good reason". Sorry I wasted your time, I don't think I'll ever get this annoying program working, maybe it just isn't for me.


#11

No at all. Looking back on my post it sounds kind of snide. Not my intention. I was trying to be good humored. Pardon my frankness. I still mean what it says, though. Don't give up. Break the problem down.

If you are going to use the Unicode approach above, then you will need a method that converts user input to usable Unicode strings.

morse = input("Enter a phrase of Morse code: ")

morse.replace('.', '\u2022')
morse.replace('-', '\u2013')

mList = morse.split(" ")

alpha = []

for x in mList:
    alpha.append(morse_dict[x])
final = ' '.join(alpha)

>>> ma = {'‒―': 'A'}
>>> ma['\u2022\u2013']
'A'
>>>

#12

Proof of concept: Morse code to standard characters converter.

morse_dict = {
    '‒–': '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', '‒––––': '1', '‒‒–––': '2', '‒‒‒––': '3', '‒‒‒‒–': '4',
    'β€’β€’β€’β€’β€’': '5',  '–‒‒‒‒': '6', '––‒‒‒': '7', '–––‒‒': '8', '––––‒': '9',
    '–––––': '0', '‒–‒–‒–': 'β€’', '––‒‒––': ',', "‒––––.": "'", '‒––––.': '"',
    '‒–‒‒–‒': '_', '‒‒––‒–': ':', '–‒–‒–‒': ';', '‒‒––‒‒': '?', '–‒–‒––': '!',
    '–‒‒‒‒–': '–', 'β€’-β€’-β€’': '+', '-β€’β€’-β€’': '/', '-β€’--.': '(', '-β€’--β€’-': ')',
    '–‒‒‒–': '=', '‒––‒–‒': '@', '\u0020': ' '
}


def morse_to_alpha(morse):
    morse.replace('.', '\u2022')
    morse.replace('-', '\u2013')
    
    mList = morse.split(" ")

    alpha = []

    for x in mList:
        alpha.append(morse_dict[x])
    return ' '.join(alpha)

nums = '‒–––– ‒‒––– ‒‒‒–– ‒‒‒‒– β€’β€’β€’β€’β€’ –‒‒‒‒ ––‒‒‒ –––‒‒ ––––‒ –––––'

print (morse_to_alpha(nums))

# 1 2 3 4 5 6 7 8 9 0

#morse_str = input("Enter a phrase of Morse code: ")

#morse_to_alpha(morse_str)

#13

Sorry for interrupting the discussion, but I would like to give one advice.

It is working only for E and T, probably because E is just "." and T is just "-", even if I wrote for example .- it printed ET. If I delete the E and T from the characters_d then it always prints "There is no symbol like that!" no matter what I type in. I got so lost in this code I no longer know what should I do know to be honest... I'll never get it working, lol...

This simply means that you don't know what happens in your code. I honestly hate those questions. You have written this code, you know why you have written it in this way. It's not like we magically know what happens in your code, we have to read it and understood it.

Do you not know why your function prints only E and T? Use a debugger (pdb module is great), I don't know why, but novice programmers are afraid of this word :slight_smile: In this case, you can use a simple print:

def from_morse(self, msg):
    output_0 = ""
    for symbols in msg:
        print(symbols)
        if symbols in self.characters_d:
            output_0 += self.characters_d[symbols]
        else:
            print('There is no symbol like that!')
    return output_0

Now, after executing this function you will notice that the for loop takes characters of msg one by one.

And now you can come here and ask - How can I split string into list of words? And this is the type of questions that I like. I would answer that you should use the str.split(separator) method, I would even provide a short example:

x = "ala ma kota"
x.split(" ") # split x into list using space as a delimiter
=> ["ala", "ma", "kota"]

After reading this example you will try to implement this solution in your code by adding this line before the for:

msg = msg.split(" ")

And now you are one step close to your goal.


#14

Ironed out some wrinkles in the above code.

def morse_to_alpha(morse):
    temp = morse.replace('.', '\u2022')
    temp = temp.replace('-', '\u2013')    
    mList = temp.split(" ")
    alpha = []
    for x in mList:
        alpha.append(morse_dict[x])
    return ' '.join(alpha)

# test the keys
nums = '‒–––– ‒‒––– ‒‒‒–– ‒‒‒‒– β€’β€’β€’β€’β€’ –‒‒‒‒ ––‒‒‒ –––‒‒ ––––‒ –––––'
print (morse_to_alpha(nums))

# test the replacement
num = '.---- ..--- ...-- ....- ..... -.... --... ---.. ----. -----'
print (morse_to_alpha(num))

# test user inputs
morse_str = input("Enter a phrase of Morse code: ")
print(morse_to_alpha(morse_str))

Enter a phrase of Morse code: ... --- ...
S O S
>>>

>>> sos = '.-.-.- .-.-.- .-.-.- -....- -....- -....- .-.-.- .-.-.- .-.-.-'

>>> morse_to_alpha(sos)
'β€’ β€’ β€’ – – – β€’ β€’ β€’'
>>>

#15

Now just how do we get the space character in there?


#16

Big thanks to both of you guys, I didn't know that it is so easy to fix, really, I totally forgot that there is .split method, this should be my first idea to be honest. Later I'll try to write questions more precisely, sorry for that. I don't think that making it to unicode is better, for me it is just the same to be honest, not much difference, it is more to write for sure, I think and maybe too complicated for this small project, but thanks, I've read it, tried it out and now I think I know a little bit more. @factoradic thanks for pointing out that I can use .split method, thanks for future advices too.

Umm, I don't understand the question, space character is already there if I'm not wrong, '\u0020': ' ' in morse_dict is space character. It is quite interesting though but I feel like this isn't much difference if it will print for example '‒‒––‒–' instead of '..-.-', maybe it is more visible or something, but I feel like I don't want to work on morse code right now for sure, maybe later when I'll get some idea or something I'll try to add something new, I think I'll work on something else right now, thought about blackjack.

Below I write my code which is finally working now

class Morse(object):
    morse_d = {'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': '--..', '1': '.----', '2': '..---', '3': '...--', '4': '....-',
               '5': '.....', '6': '-....', '7': '--...', '8': '---..', '9': '----.',
               '0': '-----', '.': '.-.-.-', ',': '--..--', "'": '.----.', '"': '.-..-.',
               '_': '..--.-', ':': '---...', ';': '-.-.-.', '?': '..--..', '!': '-.-.--',
               '-': '-....-', '+': '.-.-.', '/': '-..-.', '(': '-.--.', ')': '-.--.-',
               '=': '-...-', '@': '.--.-.', ' ': ' '}


    def to_morse(self, message):
        output = ""
        for letter in message:
            if letter.upper() in self.morse_d:
                output += self.morse_d[letter.upper()]
            else:
                print('There is no symbol like that!')
        return output

    def get_input(self):
        inp = input("Everything that you will type here will be translated to Morse Code. ")
        return inp

    def interaction(self):
        while True:
            inp = self.get_input()
            if len(inp) > 0:
                print(self.to_morse(inp))
            else:
                break

class Characters(object):
    characters_d = {'.-': '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', '.----': 1, '..---':
                    '2', '...--': '3', '....-': '4', '.....': '5',  '-....': '6', '--...': '7', '---...':
                    '8', '----.': '9', '-----': '0', '.-.-.-': '.', '--..--': ',', ".----.": "'", '.----.':
                    '"', '.-..-.': '_', '..--.-': ':', '-.-.-.': ';', '..--..': '?', '-.-.--': '!',
                    '-....-': '-', '.-.-.': '+', '-..-.': '/', '-.--.': '(', '-.--.-': ')', '-...-': '=',
                    '.--.-.': '@', "/": " "}

    def from_morse(self, msg):
        output_0 = ""
        msg = msg.split(" ")
        for symbols in msg:
            print(symbols)
            if symbols in self.characters_d:
                output_0 += self.characters_d[symbols]
            else:
                print('There is no symbol like that!')
        return output_0

    def get_input0(self):
        text = input("Everything that you will type here will be translated to alphabet from Morse Code. (space = / ) ")
        return text

    def interaction(self):
        while True:
            text = self.get_input0()
            if len(text) > 0:
                print(self.from_morse(text))
            else:
                break

    def determine(self):
        choice = input("What do you want? Translator from alphabet to Morse Code, or from Morse Code to alphabet?"
                       " Type 1 or 2. ")
        if choice == "1":
            morse = Morse()
            morse.interaction()
        elif choice == "2":
            alphabet = Characters()
            alphabet.interaction()

alphabet = Characters()
alphabet.determine()

I had to make "/": " " because .split method has " " too so I couldn't seperate words if I wanted to, so made it this way, there is probably smarter way to do this but I had already enough of writing this program so I made it like this. "If it's stupid and it's working it ain't stupid" :smiley: . I want to really thank both of you @mtf and @factoradic for help and some of the solutions that I will try to remember and use in further programs (so I will no longer have to write another topic :smiley: ). Good luck in coding guys, I hope that one day I'll be writing something bigger than just morse code translator (and I hope that I'll do it myself). I appreciate the help I've received in this topic. It's great to receive some help or advice from kind people sometimes. :slight_smile:


#17

Hi, @granatnik ,

Below is another example, written for Python 3.x, that uses double spaces to separate words in Morse code. Characters in Morse code are separated by single spaces.

See the included comments for explanation of usage and some of the implementation details.

class Morse(object):
    # Coded for Python 3.x
    # Conventions used:
    #     Morse code symbols within a word are delimited by a single space.
    #     Morse code words are delimited by a double space.
    #     If user input begins with . or -, it is assumed to be Morse code.
    def __init__(self):
        # Dictionary of text keys: Morse code values
        self.text_to_morse_dict = {'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': '--..', '1': '.----', '2': '..---', '3': '...--', '4': '....-',
               '5': '.....', '6': '-....', '7': '--...', '8': '---..', '9': '----.',
               '0': '-----', '.': '.-.-.-', ',': '--..--', "'": '.----.', '"': '.-..-.',
               '_': '..--.-', ':': '---...', ';': '-.-.-.', '?': '..--..', '!': '-.-.--',
               '-': '-....-', '+': '.-.-.', '/': '-..-.', '(': '-.--.', ')': '-.--.-',
               '=': '-...-', '@': '.--.-.', ' ': ' '}
        # Invert the dictionary.
        self.morse_to_text_dict = {self.text_to_morse_dict[key]: key for key in self.text_to_morse_dict}
        
    def to_morse(self, letters):
        # Convert text to Morse code.
        out = []
        for ch in letters:
            if ch.upper() in self.text_to_morse_dict:
                out.append(self.text_to_morse_dict[ch.upper()])
            else:
                out.append(" ")
        return " ".join(out)

    def to_text(self, mc):
        # Convert Morse code to text.
        out_list = []
        # Process each word.
        for in_word in mc.split("  "):
            word_list = []
            # Process each char within a word.
            for in_char in in_word.split(" "):
                if in_char in self.morse_to_text_dict:
                    word_list.append(self.morse_to_text_dict[in_char])
            out_list.append("".join(word_list))           
        return " ".join(out_list)

    def get_input(self):
        # Get user input.
        mess = input("Enter your message: ")
        return mess
    
    def interact_with_user(self):
        # Loop until user enters an empty string.
        while True:
            mess = self.get_input()
            if len(mess) > 0:
                if mess[0] not in ".-":
                    print(self.to_morse(mess))
                else:
                    print(self.to_text(mess))
            else:
                break

# Instantiate Morse; interact with user.
morse = Morse()
morse.interact_with_user()

#18

Which would be exactly the objective. But it also takes things off of the beaten path. It was a diversion to get you to look at procedural logic for a minute, and maybe pick up something out of the code that went with it, .split(), for instance. As I said earlier, this one is on you. We're only here to help. From the examples that our friends @factoradic and @appylpye have provided I would think we're ready for Black Jack, now.