Saturday 15 June 2024

IFSC CODE CHECKER

import re # A dictionary of some example banks and their codes banks = { "HDFC": "HDFC Bank", "ICIC": "ICICI Bank", "SBIN": "State Bank of India", "PUNB": "Punjab National Bank" } def is_valid_ifsc(ifsc_code): # Check the length if len(ifsc_code) != 11: return False, "IFSC code must be 11 characters long." # Check the format using regex if not re.match(r'^[A-Z]{4}0[A-Z0-9]{6}$', ifsc_code): return False, "IFSC code format is incorrect." # Check the bank code bank_code = ifsc_code[:4] if bank_code not in banks: return False, "Invalid bank code." # Assuming branch code validation requires a real database of branch codes # For simplicity, we'll skip this step return True, "Valid IFSC code." # Example usage ifsc_code = "HDFC0001234" is_valid, message = is_valid_ifsc(ifsc_code) print(message)

No comments:

Post a Comment