i have a program that converts text into morse code and then outputs it using a module i found in the snippets section but whenever i try to run it, it raises the error that "utext is not iterable"
here is the code:

print"Hello, what do you want to convert?"
for letter in utext:
8 Years
Discussion Span
Last Post by leegeorg07

thanks that works great, i also have a problem that i dont know the cause of, whenever i run it, it plays the entire morse code before asking the question. i have checke beeps.py and it isnt coming from that, what could it be?


and unfortunately it only removed the error, it wont play them after i have entered the text


I suppose that the sound for "a" is played when beeps.a() is called. Your program plays all the letters when you fill your dict. What you could do is forget about the dict and write this

for letter in utext:
    if hasattr(beeps, letter):
        getattr(beeps, letter)()

Also, when you have a traceback, put the traceback in your posts. It's very useful for helpers.


oh thanks, thats brilliant! i did a bit of looking around and i think that if you were to be using it in real life you would have the spaces and would use your intelligence to figure out where the would be :( but oh well, time to have some fun with this :D


i decided that i would expand it by adding in numbers but i cant really use

def 1():

can i? so i was wondering what i could do, considering i am using hassattr and getattr

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.