hey there,
i have a piece of coursework to be handed in tomorow and i am struggling to get this new bit of code that has been issued right. i have to write the pseudocode for an atm machine and one of the procedures is to validate a pin number. i already hav the following code written out but i now have to add in that the number must be between 1000 and 9000, if any one can give me an idead of where to go next this would be a big help. many thanx muddpigeon.

PROCEDURE CheckPIN
CONSTANTS
MAXPINS IS 3
VARIABLES
PINCounter IS NUMBER
BEGIN
read data from card
set PINCounter to zero
LOOP UNTIL PINCounter is equal to MAXPINS
input PIN from customer keypad
IF entered PIN matches card PIN
THEN EXITLOOP
ENDIF
add 1 to PINCounter
ENDLOOP
IF PINCounter is equal to MAXPINS
THEN confiscate customer's card
ELSE CALL PROCEDURE Services
ENDIF
END CheckPIN:cheesy:

Here is way to do it:

def check_pin(pin):
    """check if pin number pin is between 1000 and 9000"""
    if 1000 <= pin <= 9000:
        return True
    return False

pin = int(raw_input("Enter pin number (between 1000 and 9000): "))
print check_pin(pin)

thanx very much mate its really appreciated

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.