The teacher is a moron. Coconuts are not nuts and you did nothing wrong. If they want to ban coconuts because some is allergic to them, then they need to be specific, as they are not categorised as 'nuts' = like peanuts, almonds or cashews are 'nuts'.