Explain $# please

I'm trying to follow a script and I see it begins with this:

if [ $# -ne 1]; then
if [ $# -ne 2]; then
print "blah $0 blah blah "
exit
fi
fi

What does $# mean? I found out that $1 refers to the shell environment and the last argument that was entered or passed in the previous command. I couldn't find $# though. I believe this is just some sort of error checking saying "if something isn't present then stop here".

$# means the number of arguments you are passing to the script.

example :

./test.sh abc 123

for the above $# has the value of 2 ( because we are passing two arguments (abc & 123 ) to the script)

$# - total number of argument passed