I understand what you're going for with this function, but it actually will not produce an Attribute Error under all circumstances. The identifier num does not guarantee that the input will be a number. What does the function do when you call attribute_Error("42") ?