Noob question: How to check the total number of inputs entered by user?

Say I have this line:

read -p "Enter 3 numbers: " num1 num2 num3;

I want to write a while loop that repeatedly asks for input if the number of inputs entered is not equal to 3.
I don't know the correct command to find the number of inputs entered. Help, please?

Welcome on board,

I think the beginning would be to understand the line of code you posted, first...
what will read do? Why read -p ?

I'm using the

read

command to read 3 inputs, namely num1, num2, and num3. I want to write a while loop that repeatedly asks for the correct number of inputs, which is 3.

Here's the pseudocode:
read user input here (must be 3)
while the number of inputs entered is less than or greater than 3, ask again for input.
Once it exits the while loop, do the rest of the script's purpose.

Hi jejemonx...
This is what vbe was referring to assuming you are using 'bash':

Last login: Thu Dec 12 13:15:18 on ttys000
AMIGA:amiga~> bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.
AMIGA:amiga~> 
AMIGA:amiga~> 
AMIGA:amiga~> help read
read: read [-ers] [-u fd] [-t timeout] [-p prompt] [-a array] [-n nchars] [-d delim] [name ...]
    One line is read from the standard input, or from file descriptor FD if the
    -u option is supplied, and the first word is assigned to the first NAME,
    the second word to the second NAME, and so on, with leftover words assigned
    to the last NAME.  Only the characters found in $IFS are recognized as word
    delimiters.  If no NAMEs are supplied, the line read is stored in the REPLY
    variable.  If the -r option is given, this signifies `raw' input, and
    backslash escaping is disabled.  The -d option causes read to continue
    until the first character of DELIM is read, rather than newline.  If the -p
    option is supplied, the string PROMPT is output without a trailing newline
    before attempting to read.  If -a is supplied, the words read are assigned
    to sequential indices of ARRAY, starting at zero.  If -e is supplied and
    the shell is interactive, readline is used to obtain the line.  If -n is
    supplied with a non-zero NCHARS argument, read returns after NCHARS
    characters have been read.  The -s option causes input coming from a
    terminal to not be echoed.
    
    The -t option causes read to time out and return failure if a complete line
    of input is not read within TIMEOUT seconds.  If the TMOUT variable is set,
    its value is the default timeout.  The return code is zero, unless end-of-file
    is encountered, read times out, or an invalid file descriptor is supplied as
    the argument to -u.
readonly: readonly [-af] [name[=value] ...] or readonly -p
    The given NAMEs are marked readonly and the values of these NAMEs may
    not be changed by subsequent assignment.  If the -f option is given,
    then functions corresponding to the NAMEs are so marked.  If no
    arguments are given, or if `-p' is given, a list of all readonly names
    is printed.  The `-a' option means to treat each NAME as
    an array variable.  An argument of `--' disables further option
    processing.
AMIGA:amiga~> _

AND, an example of how it works:

Last login: Thu Dec 12 13:15:49 on ttys000
AMIGA:amiga~> read a b c
1
AMIGA:amiga~> echo "${a} ${b} ${c}"
1  
AMIGA:amiga~> read a b c
1 2
AMIGA:amiga~> echo "${a} ${b} ${c}"
1 2 
AMIGA:amiga~> read a b c
1 2 3
AMIGA:amiga~> echo "${a} ${b} ${c}"
1 2 3
AMIGA:amiga~> _

As you can see whether you input variables 'b' and 'c' or not they have 'NULL' values so there will always be 3 variables.
You could always use 3 separate 'read's and check each one for validity and restart the loop as required if one or more is not a number...

So your one-liner will not help you if you have more than 3, as it will not take account or will all be in num3, and if someone enters:
1,23,45 you are stuck too...
If you continue with your one-liner read, you will need num4 to be able to check more than 3 numbers were entered, after it does not matter...and you will have to check if you have a valid value in num 1-3 as what is stopping someone to enter "A"?
And while you don't have your 3 numerics in num1-3, you reinitialize your variable to 0 and start again...
---
wisecracker has also shown you what I had in mind and his suggestion solves partially your issue, only this more easy design looks like it is not an option here, as this seems more to be homework to see how smart you are to sort yourself out of this tricky issue when using in such manner the read command...
And so unless you can justify this is not homework and as such should have been posted in the adequate room and following the special rules there I will close this thread