[Python] Get the character from the alphabet position in python

Discussão em 'Python' iniciado por Stack, Abril 30, 2025.

  1. Stack

    Stack Membro Participativo

    This code gives the alphabet position of the character i want a code that i give the position and returns the alphabet

    from string import ascii_lowercase
    LETTERS = {letter: str(index) for index, letter in enumerate(ascii_lowercase, start=1)}

    def alphabet_position(text):
    text = text.lower()
    numbers = [LETTERS[character] for character in text if character in LETTERS]
    return ' '.join(numbers)

    Continue reading...

Compartilhe esta Página