Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created December 25, 2019 20:59
Show Gist options
  • Save Fhernd/94c8399466221ae0ccad6db63815fd5d to your computer and use it in GitHub Desktop.
Save Fhernd/94c8399466221ae0ccad6db63815fd5d to your computer and use it in GitHub Desktop.
# Ejercicio 419: Agregar elementos en una posición intermedia de un objeto tupla.
# Ejercicio 419: Agregar elementos en una posición intermedia de un objeto tupla.
def agregar_elementos(tupla, i, elementos):
if 0 < i < len(tupla) - 1:
return tupla[:i] + elementos + tupla[i:]
return None
numeros = (1, 2, 6, 7)
i = 2
elementos = (3, 4, 5)
resultado = agregar_elementos(numeros, i, elementos)
print(resultado)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment