It’s working in console.
May be the problem you have is that you are launching it via PyCharm or any other IDE, which has it’s own console (and is not the console used by getpass)
Running the code via a command prompt should work
CLICK HERE to find out more related problems solutions.