Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

(Word or Phrase to Phone-Number Generator) python

def transNum(string):
    number = 1

    numberElements={
        "a":2,"b":2,"c":2,
        "d":3,"e":3,"f":3,
        "g":4,"h":4,"i":4,
        "j":5,"k":5,"l":5,
        "m":6,"n":6,"o":6,
        "p":7,"q":7,"r":7,"s":7,
        "t":8,"u":8,"v":8,
        "w":9,"x":9,"y":9,"z":9,
    }

    for ch in string:
        number = numberElements[ch.lower()]
    return number

def translate(phone):
    newNum = ""
    for ch in phone:
        if ch.lower() in ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]:
            newNum = newNum + str(transNum(ch))
        else:
            newNum = newNum + ch
    return newNum

def main():
    phone = input("enter a phone number")
    noLetters = translate(phone)
    print("The number you entered: ", phone)
    print("Translates to: ", noLetters)
Comment

PREVIOUS NEXT
Code Example
Python :: Reset Python Dictionary to 0 Zero. Empty existing Python Dictionary 
Python :: how to search on wikipedia with python and speak the result 
Python :: Multiple sub in single regex. 
Python :: django form is onvalid 
Python :: statsmodels logistic regression odds ratio 
Python :: python3 main.py 
Python :: search number is complete or no python 
Python :: get maximum values in a column by a subgroup of a dataframe pandas 
Python :: pyqt5 how to check if a push button is triggered 
Python :: saving data in python 
Python :: python Hewwo wowwd 
Python :: Freqtrade - Informative Pairs 
Python :: train_ttest_split() 
Python :: total keywords in python 
Python :: performance of extend vs append loop 
Python :: python which __divs__ are there 
Python :: range coding 
Python :: .close() python 
Python :: start application from python 
Python :: python object has no attribute 
Python :: python inspect class 
Python :: signup view django 
Python :: how to make an error message in python 
Python :: python < 
Python :: if with && in python 
Python :: django class based views listview 
Python :: python find lcm 
Python :: np.vstack python 
Python :: how to make python print 2 line text in one code 
Python :: python virtual env 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =