I
I
Ilya2016-11-02 14:47:45
Python
Ilya, 2016-11-02 14:47:45

String concatenation in Python, how?

how to merge all lines into one so that the output is a merged line?

n = "Жёлудь"
for i in n.lower():
    if i == "а":
        i = "a"
    elif i == "б":
        i = "b"
    elif i == "в":
        i = "v"
    elif i == "г":
        i = "g"
    elif i == "д":
        i = "d"
    elif i == "е":
        i = "e"
    elif i == "ё":
        i = "e"
    elif i == "ж":
        i = "zh"
    elif i == "з":
        i = "z"
    elif i == "и":
        i = "i"
    elif i == "й":
        i = "i"
    elif i == "к":
        i = "k"
    elif i == "л":
        i = "l"
    elif i == "м":
        i = "m"
    elif i == "н":
        i = "n"
    elif i == "о":
        i = "o"
    elif i == "п":
        i = "p"
    elif i == "р":
        i = "r"
    elif i == "с":
        i = "s"
    elif i == "т":
        i = "t"
    elif i == "у":
        i = "u"
    elif i == "ф":
        i = "f"
    elif i == "х":
        i = "h"
    elif i == "ц":
        i = "c"
    elif i == "ч":
        i = "ch"
    elif i == "ш":
        i = "sh"
    elif i == "щ":
        i = "sh"
    elif i == "ъ":
        i = ""
    elif i == "ы":
        i = "y"
    elif i == "ь":
        i = ""
    elif i == "э":
        i = "e"
    elif i == "ю":
        i = "yu"
    elif i == "я":
        i = "ya"
    print(i)
>>> 
zh
e
l
u
d

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
DDDsa, 2016-11-02
@hugga

TRANSLIT = {'А': 'A',
            'Б': 'B',
            'В': 'V',
            'Г': 'G',
            'Д': 'D',
            'Е': 'E',
            'Ё': 'YO',
            'Ж': 'ZH',
            'З': 'Z',
            'И': 'EE',
            'Й': 'J',
            'К': 'K',
            'Л': 'L',
            'М': 'M',
            'Н': 'N',
            'О': 'O',
            'П': 'P',
            'Р': 'R',
            'С': 'S',
            'Т': 'T',
            'У': 'U',
            'Ф': 'F',
            'Х': 'H',
            'Ц': 'C',
            'Ч': 'CH',
            'Ш': 'SH',
            'Щ': 'SCH',
            'Ъ': '',
            'Ы': 'I',
            'Ь': '',
            'Э': 'E',
            'Ю': 'U',
            'Я': 'YA'}

def translit(text):
    result = []
    for c in text:
            result.append(TRANSLIT.get(c.upper(), c))
    return ''.join(result)

A
axblue, 2017-01-12
@tereshock98

https://codepen.io/kerrin/pen/ezqwC/
or so
codepen.io/littlesnippets/pen/grozvB
there are many options on codepen

A
Andrey Fedorov, 2017-01-12
@aliencash

Лол. А мне кажется вы хотите, чтобы мы сделали за вас галерею. ))) Разместите в вопросе код своих попыток.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question