Eduardo Daltro
Eduardo Daltro

Reputation: 81

Convert language to country code with Python

Is it possible to identify the country code number by language?

It would look something like this:

>>> lang = 'en'
>>> print(lang.country_code)
>>> '+1'

I searched the phonenumbers and pycountry libs, but I couldn't find anything like that.

Upvotes: 1

Views: 708

Answers (2)

Shashank
Shashank

Reputation: 103

You can create a dictionary here with country code like dict ={ "country1": 1234, "country2": 234, "country3": 1964 } and then wherever you want to use it, you can run loop to print the key value using key.

Upvotes: 0

Epic Martijn
Epic Martijn

Reputation: 345

I found a JSON containing the requirements of your question, you'll just have to write some code to get the right values from it.

link

Upvotes: 2

Related Questions