Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solución reto#31 Python #1372

Open
grisales54 opened this issue Oct 6, 2024 · 0 comments
Open

Solución reto#31 Python #1372

grisales54 opened this issue Oct 6, 2024 · 0 comments

Comments

@grisales54
Copy link

`
def marco(frase: str):

# Dividimos la frase en una lista de palabras
frase_list = frase.split()

# Inicializamos una variable para guardar la longitud de la palabra más larga
mayor = max(len(i) for i in frase_list)
# Imprimimos la línea superior del marco
print("*" * mayor + "*" * 2)
# Iteramos sobre cada palabra en la lista
for j in frase_list:
    x = list(j)
    # Imprimimos cada palabra con el formato requerido
    print("*" + j + " " * (mayor - len(x)) + "*")
# Imprimimos la línea inferior del marco
print("*" * mayor + "*" * 2)

frase = "Hola mundo ¿cómo estás?"

marco(frase)
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant