Check if a number is an Iban number using Python

Updated

Iban number is the number N such that the number does not contain the letter “I” in itself. Simply Iban means I is banned.

The few Iban numbers are:

0, 1, 2, 3, 4, 7, 10, 11, 12, 14, 17, 20, 21, 22, 23, 24, 27, 40, 41, 42, 43, 44, 47, …

Check if N is an Iban number :

Given a number N, the task is to check if N is an Iban Number or not. If N is an Iban Number then print “Yes” else print “No”.

Examples :

Input : N = 4
Output : Yes
Explanation :
4 -> Four and it does not contains "i" so it is an Iban Number

Input : N = 16
Output : No

Approach :

The idea is to convert number N into a string of word. Now check if the string contains the letter “I” or not. If the string does not contain the letter “I” then the number is a Iban number.

Implementation :

# Python implementation of the above approach

# strings at index 0 is not used, it  
# is to make array indexing simple 	
one = [ "", "one ", "two ", "three ", "four ", 
        "five ", "six ", "seven ", "eight ", 
        "nine ", "ten ", "eleven ", "twelve ", 
        "thirteen ", "fourteen ", "fifteen ", 
        "sixteen ", "seventeen ", "eighteen ", 
        "nineteen "]; 
  
# strings at index 0 and 1 are not used,  
# they is to make array indexing simple 
ten = [ "", "", "twenty ", "thirty ", "forty ", 
        "fifty ", "sixty ", "seventy ", "eighty ", 
        "ninety "]; 
  
# n is 1- or 2-digit number 
def numToWords(n, s): 
  
    str = ""; 
      
    # if n is more than 19, divide it 
    if (n > 19): 
        str += ten[n // 10] + one[n % 10]; 
    else: 
        str += one[n]; 
  
    # if n is non-zero 
    if (n): 
        str += s; 
  
    return str; 
  
# Function to print a given number in words 
def convertToWords(n): 
  
    # stores word representation of given  
    # number n 
    out = ""; 
  
    # handles digits at ten millions and  
    # hundred millions places (if any) 
    out += numToWords((n // 10000000),  
                            "crore "); 
  
    # handles digits at hundred thousands  
    # and one millions places (if any) 
    out += numToWords(((n // 100000) % 100), 
                                   "lakh "); 
  
    # handles digits at thousands and tens  
    # thousands places (if any) 
    out += numToWords(((n // 1000) % 100),  
                             "thousand "); 
  
    # handles digit at hundreds places (if any) 
    out += numToWords(((n // 100) % 10),  
                            "hundred "); 
  
    if (n > 100 and n % 100): 
        out += "and "; 
  
    # handles digits at ones and tens 
    # places (if any) 
    out += numToWords((n % 100), ""); 
  
    return out; 

# Function to check the number is
# Iban number or not.
def isiban(n):
    word = convertToWords(n)
    if ("i" in word) or ("I" in word):
        return False
    return True
	
# Driver code 
n = 10
if isiban(n):
    print("Yes")
else:
    print("No")

Output :

Yes

Using Python Function: In this approach, num2words module is import and num2words function is used to convert number into the words.

Note : To run this program num2words is need to be install.

from num2words import num2words

# Function to convert number N into
# a string of word.
def convertToWords(n):
    return num2words(n)
    
# Function to check the number is
# Iban number or not.
def isiban(n):
    word = convertToWords(n) 
    if ("i" in word) or ("I" in word):
        return False
    return True
	
# Driver code 
n = 10
if isiban(n):
    print("Yes")
else:
    print("No")

Output :

Yes
Comment
Mithlesh Upadhyay Published 29 Nov 2026 · 3 min read

Mithlesh Upadhyay is a Computer Science and AI expert from Madhya Pradesh with strong academic background (BE in CSE and M.Tech in AI) and over six years of experience in technical content development. He has contributed tech articles, led teams, and worked in Full Stack Development and Data Science. He founded the w3colleges.org portal for learning resources.

Related tutorials