Gematria is an Assyro-Babylonian-Greek system of code and numerology later adopted into Jewish culture. The system assigns numerical value to a word or a phrase in the belief that words or phrases with identical numerical values bear some relation to each other or bear some relation to the number itself. While more commonly used on Hebrew words, there is also an English version.

Each letter has a value and the gematrian value of a word or a phrase is the sum of those values. The code takes a word or an expression and returns the gematrian value of it.

The calculation is case insensitive and counts no spaces. 

Example: The gematrian value of "love" is 20+50+700+5 = 775

‎These are the values of the different letters:

a=1, b=2, c=3, d=4, e=5, f=6, g=7, h=8, i=9, k=10, l=20,
m=30, n=40, o=50, p=60, q=70, r=80, s=90, t=100, u=200,
x=300, y=400, z=500, j=600, v=700, w=900

Difficulty: introductory

Starter code:

def gematria(string):
	

Solutions:


TOME = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8, 'i':9, 'k':10, 'l':20, 'm':30, 'n':40, 'o':50, 'p':60, 'q':70, 'r':80, 's':90, 't':100, 'u':200, 'x':300, 'y':400, 'z':500, 'j':600, 'v':700, 'w':900}

def gematria(s): return sum(TOME.get(c,0) for c in s.lower())

def gematria(string):
    d = dict(a=1, b=2, c=3, d=4, e=5, f=6, g=7, h=8, i=9, k=10, l=20, m=30, n=40, o=50, p=60, q=70, r=80, s=90, t=100, u=200, x=300, y=400, z=500, j=600, v=700, w=900)
    return sum(d.get(x, 0) for x in string.lower())

letters = {
    'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'k': 10,
    'l': 20, 'm': 30, 'n': 40, 'o': 50, 'p': 60, 'q': 70, 'r': 80, 's': 90, 't': 100,
    'u': 200, 'x': 300, 'y': 400, 'z': 500, 'j': 600, 'v': 700, 'w': 900,
}

def gematria(s):
    return sum(letters.get(c, 0) for c in s.lower())

values = {"a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6, "g": 7, "h": 8, "i": 9,
          "k": 10, "l": 20, "m": 30, "n": 40, "o": 50, "p": 60, "q": 70, "r": 80, "s": 90,
          "t": 100, "u": 200, "x": 300, "y": 400, "z": 500, "j": 600, "v": 700, "w": 900}

def gematria(string):
    return sum(values.get(c, 0) for c in string.lower())

def gematria(string):
    #your code here
    sum = 0
    string = string.lower()
    num = {'a' : 1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7,' ':0,
    'h':8, 'i':9, 'k':10, 'l':20, 'm':30, 'n':40, 'o':50, 'p':60, 'q':70, 'r':80,
    's':90, 't':100, 'u':200, 'x':300, 'y':400, 'z':500, 'j':600, 'v':700, 'w':900}
    for key in string:
        if key in num.keys():
            sum += num[key]
    return sum

def gematria(string):
    #your code here
    dicts = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8, 'i':9,
    'k':10, 'l':20, 'm':30, 'n':40, 'o':50, 'p':60, 'q':70, 'r':80, 's':90, 
    't':100, 'u':200, 'x':300, 'y':400, 'z':500, 'j':600, 'v':700, 'w':900}
    sum = 0
    strings = ''.join([x for x in string if x.isalpha()])
    for c in str.lower(strings):
        sum += dicts[c]
    return sum


gematria = lambda s, d=dict(a=1, b=2, c=3, d=4, e=5, f=6, g=7, h=8, i=9, k=10, l=20, m=30, n=40, o=50, p=60, q=70, r=80, s=90, t=100, u=200, x=300, y=400, z=500, j=600, v=700, w=900): sum(map(d.get, filter(str.islower, s.lower())))

from string import ascii_lowercase
def gematria(strng):
    values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 600, 10, 20, 30, 40, 50, 60 , 70, 80, 90, 100, 200, 700, 900, 300, 400, 500]
    alphabet_values = { letter:num for num,letter in zip(values, ascii_lowercase)  }
    return sum([alphabet_values[letter] if letter in ascii_lowercase else 0 for letter in strng.lower()])

D = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8, 'i':9, 'k':10, 'l':20, 'm':30, 
     'n':40, 'o':50, 'p':60, 'q':70, 'r':80, 's':90, 't':100, 'u':200, 'x':300, 'y':400, 'z':500, 'j':600, 'v':700, 'w':900}
     
def gematria(s):
    return sum(D.get(c, 0) for c in s.lower())

gematria=lambda s,D=dict(a=1, b=2, c=3, d=4, e=5, f=6, g=7, h=8, i=9, k=10, l=20, m=30, n=40, o=50, p=60, q=70, r=80, s=90, t=100, u=200, x=300, y=400, z=500, j=600, v=700, w=900):sum(D.get(k,0)for k in s.lower())