-1
    code = {

        "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" : "--.. ",

        }




    def morse(word):
    for i in word:
        if i == " ":
            print(" " * 2, end="")
        else:
            print(code[i], end="")

word = input("Type A Sentence: ")
word = list(word.upper())
print(morse(word))

how do I remove the "none" after this is ran? because running this prints out none at the end.

everything seems to be working fine except for that none at the end

Type A Word: hello .... . .-.. .-.. --- None

Halcyon Abraham Ramirez
  • 1,520
  • 1
  • 16
  • 17
  • You're doing a `print` in two places, one where you call `morse` and another inside the function itself. You should only print once. You have a choice, have `morse` return a string and print that string (and remove the print calls there), or remove the `print` from the place where you call `morse`. The more flexible choice would be to have `morse` return a string. – Mark Ransom Apr 10 '15 at 16:47

1 Answers1

2

The morse function doesn't return anything so print(morse(word)) prints None. You can fix this by not printing the return value:

morse(word)
Simeon Visser
  • 118,920
  • 18
  • 185
  • 180
  • wow that was fast and the solution was really simple. thank you! I am very new to python and this is my first project. It's not stellar or anything but hey. it's something! Thank you very much – Halcyon Abraham Ramirez Apr 10 '15 at 16:55