Skip to content

Instantly share code, notes, and snippets.

@nebil
Last active October 31, 2018 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nebil/c7765ad570b6877800dbfc4a7df283e3 to your computer and use it in GitHub Desktop.
Save nebil/c7765ad570b6877800dbfc4a7df283e3 to your computer and use it in GitHub Desktop.
🐍 Un script que verifica si Python 3.6+ está instalado 🐍
"""
Esto es un simple script para verificar que Python 3.6+ esté instalado.
Copyright (c) 2018, Nebil Kawas García
This source code is subject to the terms of the Mozilla Public License.
You can obtain a copy of the MPL at <https://www.mozilla.org/MPL/2.0/>.
"""
from string import ascii_letters
from platform import python_version
def get_next(letter):
"""
Dada una letra, devuelve la siguiente, según el orden de `ascii_letters`.
Si esta letra no está en ese conjunto, entonces entregará la misma letra.
Veamos algunos ejemplos.
>>> get_next('a')
'b'
>>> get_next('h')
'i'
>>> get_next('z')
'A'
>>> get_next('X')
'Y'
>>> get_next('Z')
'a'
>>> get_next('ñ')
'ñ'
"""
index = ascii_letters.find(letter)
return letter if index == -1 else ascii_letters[(index + 1) % 52]
if __name__ == '__main__':
message = (f'¡GnkZ! Drsn dr tm didlokn drbqhsn oZqZ Oxsgnm 3.6+.\n'
f'Rh otdcdr kddq drsd ldmrZid, dmsnmbdr sncn drsá NJ.\n'
f'St udqrhóm dwZbsZ cd Oxsgnm dr: {python_version()}.\n')
print(''.join(map(get_next, message)))
input('Oprime [Enter] para salir.\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment