validation - How to make a program that verifies Card Security Codes in python? -


I want to create a program confirming card security code in Python (CSC, 3-digit security code on credit card) I am I want to write a simple program that checks whether a given code is valid or not. The code is valid if all three letters are entered between digits 0 and 9. If the CSC is valid, then I should say that it is a legitimate message and a different message is saying that it is not valid if the code entered does not include three digits.

I wrote the following code but I know it is wrong. How can I write it but keep it short and simple? raw_input ("Please enter CSC:") if the code [0] limits [0, 10] and the code [1] limits [0,10] and the code [2] range In [0,10]: Print "Thank you. We will process your order!" else: print "The verification code was not valid. Please check your credit card code again."

Appreciate your help!

You can check to see if the length is correct:

  If len (code) == 3:   

and check to see that this is a number:

  if code.isdigit ( ):  Edit:  Correct syntax:  
  if LAN (code) == 3 and code.isdigit () :    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -