I don't know what terminal the OP is using - probably the built-in terminal (Terminal.app), but in case anyone has this problem with iTerm2, here is what fixed it for me:
In iTerm2 Preferences > Keys > Navigation Shortcuts > "Shortcut to choose a split pane" was
opt+3 was mapped to focus the 3rd pane in your tab had been split into panes, but this was overriding the normal mapping of
#. I changed it to "No shortcut" and could then type hash symbols in iTerm.
I never had this problem before, but recently bought a new MacBook Pro M1 with MacOS Monterey, installed iTerm2 on it amongst other things, and then was was amazed to find that I couldn't type a hash symbol in the terminal - for example, for making comments in Python code or Bash scripts. I certainly didn't set it that way - so it must have been in the default setup of iTerm2. Why on earth the developers thought that was a good setting to have on by default, I don't know.
alt-3, e.g. in a text editor? Does it work in
bash; is the error just happening in
nano? If you enter
readin bash, press enter, then press
alt-3, what happens?
altis also used as modifier for keyboard shortcuts.
Shift-3for the pound character
altkey, maybe it's
Alt-Grand changes things?