My Projects

 4. Seplin language

SEPLIN IS A SECRET CODING LANGUAGE. AND THIS PROGRAM IS A SEPLIN CONVERTER.

from random import choice
see1 = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
        'j', 'o', 'm', 'x', 'y', 'z', 'a', 'b', 'z')
dee1 = ('k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
        's', 't', 'u', 'a', 'z', 'w', 'v', 'x', 'y', 'z', 'a', 'b', 'p')
vee1 = ('w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e')
see = choice(list(see1))
dee = choice(list(dee1))
vee = choice(list(vee1))


def run():
    """
    Seplin T0 English and English T0 Seplin Converter
    Coder : Hashir Ahmad
    """
    d = input('Do want to code or decode? Enter quit to exit. \n Enter: ')
    if d == 'code':
        while True:
            s = input('Enter the Sentence|word or q to exit: ').lower()
            if s == 'q':
                print('Thanks for using...')
                break
            if '.' in s:
                s = s.rstrip('.')
            if ',' in s:
                s = s.rstrip(',')
            sent = s.split(' ')
            nsent = []
            for word in sent:
                see = choice(list(see1))
                dee = choice(list(dee1))
                vee = choice(list(vee1))
                if len(word) >= 3:
                    r = word[0]
                    p = word[2:]
                    q = word[1]
                    nsent.append(see + dee + vee + p + r + q + dee + vee +
                                 see)

                else:
                    nsent.append(word[::-1]+dee+vee + see)
                see = choice(list(see))
                dee = choice(list(dee))
                vee = choice(list(vee))
            print(' '.join(nsent))
    elif d == 'decode':
        while True:
            g = input('Enter the code or q to exit: ').lower()
            sent = g.split(' ')
            nsent = []
            if g == 'q':
                print('Thanks for using...')
                break
            for word in sent:
                if len(word) >= 9:
                    h = word[3:len(word) - 3]
                    j = h[-1]
                    l = h[-2]
                    ans = l + j + h[:-1]
                    nsent.append(ans[:len(ans)-1])
                elif len(word) == 5:
                    n = word[:len(word)-3]
                    h = n[::-1]
                    nsent.append(h)
                elif len(word) < 5:
                    n = word[0]
                    nsent.append(n)
                else:
                    print('Invalid code')
            print(' '.join(nsent))
    elif d == 'quit':
        q = 0
        print('program exited...............')
    else:
        print('Wrong Input')
        return run()


if __name__ == '__main__':
    run()

Comments

  1. I have recently updated this code to make it good and readable plus simple.

    ReplyDelete

Post a Comment

Popular posts from this blog

Advance Calculator Made For Mathematicans and Coders | Made with Python

Functions Module