Random Phone Number Generator

  • Share this:

Code introduction


This function takes a country code and a phone number format as arguments, and then generates a random phone number that matches the specified format and country using the Faker library.


Technology Stack : Faker

Code Type : Function

Code Difficulty : Intermediate


                
                    
def generate_random_phone_number(country_code, phone_number_format):
    from faker import Faker
    fake = Faker()
    return fake.phone_number(format=phone_number_format, country_code=country_code)                
              
Tags: