{"id":118,"date":"2014-02-04T08:31:23","date_gmt":"2014-02-04T08:33:59","guid":{"rendered":"https:\/\/8b164python.jpg"},"modified":"2015-07-16T20:00:52","modified_gmt":"2015-07-17T02:00:52","slug":"codigo-python-insertar-un-elemento-en-una-lista","status":"publish","type":"post","link":"https:\/\/emanuelpaxtian.com\/blog\/codigo-python-insertar-un-elemento-en-una-lista\/","title":{"rendered":"C\u00f3digo Python &#8211;  Insertar Un Elemento en una Lista"},"content":{"rendered":"<p>Ejemplo en python de como insertar un elemento en una lista de elementos.<\/p>\n<pre class=\"brush:python\">import random\r\n\r\ndef insertarElemento(lista, indice, elemento):\r\n    lista.insert(indice,elemento)\r\n\r\ndef imprimirLista(lista,nombre):\r\n    for i in range(0,len(lista)):\r\n        print nombre + \"[\" + str(i) + \"]=\" + str(lista[i])\r\n\r\ndef leerLista():\r\n    lista=[]\r\n\r\n    i=0\r\n    while i &lt; 10:\r\n        lista.append(int(random.randint(0, 10)))\r\n        i=i+1\r\n    return lista\r\n\r\nA=leerLista()\r\nimprimirLista(A,\"A\")\r\ncn_val=int(raw_input(\"Ingrese Valor: \"))\r\ncn_ind=int(raw_input(\"Ingrese Indice: \"))\r\ninsertarElemento(A,cn_ind,cn_val)\r\nimprimirLista(A,\"A\")\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Ejemplo en python de como insertar un elemento en una lista de elementos. import random def insertarElemento(lista, indice, elemento): lista.insert(indice,elemento) def imprimirLista(lista,nombre): for i in range(0,len(lista)): print nombre + &#8220;[&#8220;&hellip;<\/p>\n","protected":false},"author":1,"featured_media":396,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-118","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts\/118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/comments?post=118"}],"version-history":[{"count":0,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/posts\/118\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/media\/396"}],"wp:attachment":[{"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/media?parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/categories?post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/emanuelpaxtian.com\/blog\/wp-json\/wp\/v2\/tags?post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}