Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Last active July 18, 2022 18:57
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 parzibyte/f2b7d51c6e3c31f9fe172f150b157933 to your computer and use it in GitHub Desktop.
Save parzibyte/f2b7d51c6e3c31f9fe172f150b157933 to your computer and use it in GitHub Desktop.
def empieza_con(cadena, subcadena):
longitud_subcadena = len(subcadena)
extraido = cadena[0:longitud_subcadena]
if extraido == subcadena:
return True
else:
return False
print(empieza_con("Hola", "H")) # True
print(empieza_con("Hola", "h")) # False
print(empieza_con("Parzibyte", "e")) # False
print(empieza_con("Me gusta programar en Python desde parzibyte.me", "Me gu")) # True
print(empieza_con("Hola", "Hola mundo")) # False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment