My Coding Quiz #47
My Coding Quiz #47 👨💻🛠️🧩
Welcome to the new installment of my series of Coding Quizzes, in which you will be able to test your knowledge and skills about programming and software development in a simple and fun way. If you want to learn more about it visit my blog here on Hive and the first post where I introduced it.
Without further ado, here's the riddle...
By
@eniolw
What's your choice?
Solution to the previous quiz: 'eniolw.com '. This riddle script is simple. It all comes down to knowing the built-in lstrip method. Do you know what it does? Well, it removes all the characters you provide as arguments from the string where it is applied, as long as those characters are at the beginning of the string.
As in our code we specified txt.lstrip("@."), both @ and . will be removed from the initial part of the string contained in txt. That string is "@eniolw.com ", so the function removes the @ character, but not the . character, since it cannot be considered to be at the beginning of the string. As a consequence, the given characters that do not satisfy that condition are ignored without raising an exception.
The resulting new string stored in the variable res is "eniolw.com ". Note that the lstrip method does the above, but it does not remove the whitespaces at the beginning and end of the string, as the strip method would do, which is why the whitespace at the end is preserved here. Did you know this or were you tricked?
Frankly, I find the lstrip method unusual, but it may have some applications. It can be useful for removing that @ as we already saw, and it can also remove other prefixes like https://, etc.
If you want to blog about computer science and programming content, I invite you to join Hive and participate in its communities, such as STEM-social, Develop Spanish, Programming & Dev and others.
Mi Quiz de Programación #47 👨💻🛠️🧩
Bienvenido a mi nueva serie de Quizzes de Programación, en la cual podrás poner a prueba tus conocimientos y habilidades sobre programación y desarrollo de software de una manera sencilla y divertida. Si quieres aprender más sobre ella visita mi blog aquí en Hive y el primer post donde la presenté.
Sin más preámbulos, he aquí el acertijo...
Por
@eniolw
¿Cuál es tu elección?
Solución al quiz anterior: 'eniolw.com '. Este script de acertijo es simple. Todo se reduce a conocer el método integrado lstrip. ¿Sabes lo que hace? Bueno, elimina todos los caracteres que proporcionas como argumentos de la cadena donde se aplica, siempre que esos caracteres estén al principio de la cadena.
Como en nuestro código especificamos txt.lstrip("@."), tanto @ como . se eliminarán de la primera parte de la cadena contenida en txt. Esa cadena es "@eniolw.com ", por lo que la función elimina el carácter @, pero no el carácter ., ya que no se puede considerar que está al principio de la cadena. Como consecuencia, los caracteres dados que no cumplen esa condición se ignoran sin generar una excepción.
La nueva cadena resultante almacenada en la variable res es "eniolw.com ". Ten en cuenta que el método lstrip hace lo anteriormente dicho, más no elimina los espacios en blanco al principio y al final de la cadena, como lo haría el método strip, razón por la cual el espacio en blanco al final se conserva aquí. ¿Sabías esto o te dejaste truquear?
Francamente, el método lstrip me parece inusual, pero puede tener algunas aplicaciones. Puede ser útil para eliminar ese @ como ya vimos, y también puede eliminar otros prefijos como https://, etc.
Si quieres bloguear sobre contenido informático y de programación, te invito a unirte a Hive y participar en sus comunidades, tales como STEM-social, Develop Spanish, Programming & Dev y otras.
Leave My Coding Quiz #47 to:
Read more #hive-197685 posts
Best Posts From Enio
We have not curated any of eniolw's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Enio
- Chess Puzzle of the Day (Jul 27, 2026) | Problema de ajedrez del día (27-Jul-2026)
- Chess Puzzle of the Day (Jul 26, 2026) | Problema de ajedrez del día (26-Jul-2026)
- Chess Puzzle of the Day (Jul 25, 2026) | Problema de ajedrez del día (25-Jul-2026)
- Chess Puzzle of the Day (Jul 25, 2026) | Problema de ajedrez del día (25-Jul-2026)
- A Chess Puzzle | Un problema de ajedrez del día
- Chess Puzzle of the Day (Jul 24, 2026) | Problema de ajedrez del día (24-Jul-2026)
- Chess Puzzle of the Day (Jul 23, 2026) | Problema de ajedrez del día (23-Jul-2026)
- Chess Puzzle of the Day (Jul 22, 2026) | Problema de ajedrez del día (22-Jul-2026)
- Chess Puzzle of the Day (Jul 21, 2026) | Problema de ajedrez del día (21-Jul-2026)
- Chess Puzzle of the Day (Jul 20, 2026) | Problema de ajedrez del día (20-Jul-2026)