{"id":39330,"date":"2016-11-24T19:50:00","date_gmt":"2016-11-25T01:50:00","guid":{"rendered":"https:\/\/kenscourses.com\/tc101fall2016\/?guid=0134bba0d186e22d75db8ea6bd2c636e"},"modified":"2016-11-24T19:50:48","modified_gmt":"2016-11-25T01:50:48","slug":"programming-and-hobbies-2016-11-24-195000","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/programming-and-hobbies-2016-11-24-195000\/","title":{"rendered":"Programming and Hobbies 2016-11-24 19:50:00"},"content":{"rendered":"<p class=\"syndicated-attribution\"><em> --Originally published at <a href=\"http:\/\/christa-vanilla98.blogspot.com\/2016\/11\/validated-user-input-en-esta.html\"><a href=\"http:\/\/christa-vanilla98.blogspot.com\/\">Programming and Hobbies<\/a><\/a><\/em><br \/><\/p>\n<div style=\"text-align: center;\"><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\"><span style=\"color: #e06666;\"><u>Validated user input<\/u><\/span><\/span><\/div><br \/><br \/><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\">En esta publicaci\u00f3n los mostrar\u00e9 un ejemplo bastante sencillo para comprobar que la informaci\u00f3n proporcionada por el usuario es v\u00e1lida.<\/span><br \/><br \/><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\">Lo primero que debemos hacer es escribir un while true para generar un loop y \u00e9ste pueda repetirse hasta recibir un dato v\u00e1lido y despu\u00e9s debemos escribir una variable para nuestro input. (En este caso yo quise utilizar una sola letra \"n\").<\/span><br \/><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\">&nbsp;<\/span><br \/><div class=\"separator\" style=\"clear: both; text-align: center;\"><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\"><img border=\"0\" height=\"360\" src=\"https:\/\/1.bp.blogspot.com\/-Hl8bHLKZwNU\/WDeGVw0UYCI\/AAAAAAAAEbU\/730Hbp6suvcYObLDABAMSgM2sf-Yq5bVwCLcB\/s640\/Captura%2Bde%2Bpantalla%2B2016-11-24%2B18.30.58.png\" width=\"640\" \/>&nbsp;<\/span><\/div><div class=\"separator\" style=\"clear: both; text-align: left;\"><br \/><\/div><div class=\"separator\" style=\"clear: both; text-align: left;\"><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\">Una vez que tenemos nuestra primer parte del loop, debemos agregar nuestra excepci\u00f3n.<\/span><\/div><div class=\"separator\" style=\"clear: both; text-align: left;\"><br \/><\/div><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"https:\/\/1.bp.blogspot.com\/-w6gg_h18Hw4\/WDeHcpFpYjI\/AAAAAAAAEbY\/S1jPNwE0UCkbqKKjyK68ju5q1sSsQqAcgCLcB\/s1600\/Captura%2Bde%2Bpantalla%2B2016-11-24%2B18.35.29.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img border=\"0\" height=\"360\" src=\"https:\/\/1.bp.blogspot.com\/-w6gg_h18Hw4\/WDeHcpFpYjI\/AAAAAAAAEbY\/S1jPNwE0UCkbqKKjyK68ju5q1sSsQqAcgCLcB\/s640\/Captura%2Bde%2Bpantalla%2B2016-11-24%2B18.35.29.png\" width=\"640\" \/><\/a><\/div><div class=\"separator\" style=\"clear: both; text-align: left;\"><br \/><\/div><div class=\"separator\" style=\"clear: both; text-align: left;\"><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\">Y agregu\u00e9 \"continue\", ya que loop seguir\u00e1 repiti\u00e9ndose hasta que el usuario inserte un n\u00famero entero.<\/span><\/div><div class=\"separator\" style=\"clear: both; text-align: left;\"><br \/><\/div><div class=\"separator\" style=\"clear: both; text-align: left;\"><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\">Si finalmente el usuario introdujo el valor adecuado, entonces el loop se \"romper\u00e1\" y se podr\u00e1 continuar con las dem\u00e1s instrucciones del c\u00f3digo.<\/span><\/div><div class=\"separator\" style=\"clear: both; text-align: left;\"><br \/><\/div><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"https:\/\/1.bp.blogspot.com\/-vo6XWVBuT0s\/WDeIEgvDpdI\/AAAAAAAAEbg\/276DndfPp_8FqBdV1CrDJK8gpLasEmEJwCLcB\/s1600\/Captura%2Bde%2Bpantalla%2B2016-11-24%2B18.38.28.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img border=\"0\" height=\"360\" src=\"https:\/\/1.bp.blogspot.com\/-vo6XWVBuT0s\/WDeIEgvDpdI\/AAAAAAAAEbg\/276DndfPp_8FqBdV1CrDJK8gpLasEmEJwCLcB\/s640\/Captura%2Bde%2Bpantalla%2B2016-11-24%2B18.38.28.png\" width=\"640\" \/><\/a><\/div><div class=\"separator\" style=\"clear: both; text-align: left;\"><br \/><\/div><div class=\"separator\" style=\"clear: both; text-align: left;\"><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\">Ahora que saben lo b\u00e1sico, har\u00e9 un ejemplo en el cual tambi\u00e9n se incluya un condicional \"if\".<\/span><\/div><div class=\"separator\" style=\"clear: both; text-align: left;\"><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\"><br \/><\/span><\/div><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"https:\/\/2.bp.blogspot.com\/-DyVIVo-psbQ\/WDeXSvLGuZI\/AAAAAAAAEbw\/I57_SplnDs48RdlsIzfhSieIHO1SEgfFACLcB\/s1600\/Captura%2Bde%2Bpantalla%2B2016-11-24%2B19.43.12.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img border=\"0\" height=\"360\" src=\"https:\/\/2.bp.blogspot.com\/-DyVIVo-psbQ\/WDeXSvLGuZI\/AAAAAAAAEbw\/I57_SplnDs48RdlsIzfhSieIHO1SEgfFACLcB\/s640\/Captura%2Bde%2Bpantalla%2B2016-11-24%2B19.43.12.png\" width=\"640\" \/><\/a><\/div><div class=\"separator\" style=\"clear: both; text-align: left;\"><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\"><br \/><\/span><\/div><div class=\"separator\" style=\"clear: both; text-align: left;\"><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\">Ahora comprobaremos que si introducimos cualquier valor que no sea el requerido se realizar\u00e1 nuestro loop.<\/span><\/div><div class=\"separator\" style=\"clear: both; text-align: left;\"><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\"><br \/><\/span><\/div><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"https:\/\/1.bp.blogspot.com\/-aZBFl8kh9yA\/WDeXuJTqLyI\/AAAAAAAAEb0\/GnpDeYBCEeMCkCdjcvROB15_VUja-XJFACLcB\/s1600\/Captura%2Bde%2Bpantalla%2B2016-11-24%2B19.44.46.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img border=\"0\" height=\"360\" src=\"https:\/\/1.bp.blogspot.com\/-aZBFl8kh9yA\/WDeXuJTqLyI\/AAAAAAAAEb0\/GnpDeYBCEeMCkCdjcvROB15_VUja-XJFACLcB\/s640\/Captura%2Bde%2Bpantalla%2B2016-11-24%2B19.44.46.png\" width=\"640\" \/><\/a><\/div><div class=\"separator\" style=\"clear: both; text-align: left;\"><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\"><br \/><\/span><\/div><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\">Podemos seguir introduciendo datos erroneos para comprobar que nuestro programa funciona correctamente.<\/span><br \/><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\"><br \/><\/span><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"https:\/\/4.bp.blogspot.com\/-kESqbWEuki8\/WDeYKBav4cI\/AAAAAAAAEb8\/7tKxBU-66IAUtkF-QSkSIMtulF0D18TYQCLcB\/s1600\/Captura%2Bde%2Bpantalla%2B2016-11-24%2B19.46.44.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img border=\"0\" height=\"360\" src=\"https:\/\/4.bp.blogspot.com\/-kESqbWEuki8\/WDeYKBav4cI\/AAAAAAAAEb8\/7tKxBU-66IAUtkF-QSkSIMtulF0D18TYQCLcB\/s640\/Captura%2Bde%2Bpantalla%2B2016-11-24%2B19.46.44.png\" width=\"640\" \/><\/a> <\/div><br \/><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\">Tambi\u00e9n es importante comprobar que al introducir nuestros posibles valores dentro de nuestro condicional se muesta la respuesta correcta.<\/span><br \/><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\"><br \/><\/span><div class=\"separator\" style=\"clear: both; text-align: center;\"><a href=\"https:\/\/1.bp.blogspot.com\/-ZvCUvXQz9VA\/WDeYKIXEefI\/AAAAAAAAEb4\/zekApq2M9447YO0kUMmHhpTr1QFgyOijACEw\/s1600\/Captura%2Bde%2Bpantalla%2B2016-11-24%2B19.47.03.png\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img border=\"0\" height=\"360\" src=\"https:\/\/1.bp.blogspot.com\/-ZvCUvXQz9VA\/WDeYKIXEefI\/AAAAAAAAEb4\/zekApq2M9447YO0kUMmHhpTr1QFgyOijACEw\/s640\/Captura%2Bde%2Bpantalla%2B2016-11-24%2B19.47.03.png\" width=\"640\" \/><\/a><\/div><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\"><br \/><\/span><div class=\"separator\" style=\"clear: both; text-align: center;\"><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\">&nbsp;Y b\u00e1sicamente esto es todo, si tienen dudas pueden dejarlas en este post o mandarlas a mi twitter&nbsp;<a href=\"https:\/\/twitter.com\/Vanilla_Berry98\" >https:\/\/twitter.com\/Vanilla_Berry98<\/a><\/span><\/div><div class=\"separator\" style=\"clear: both; text-align: center;\"><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\">&nbsp;<\/span><a href=\"https:\/\/4.bp.blogspot.com\/-zfaLCLsVE7Q\/WDeYoP1HqzI\/AAAAAAAAEcI\/Bpxx9lh2f3wWbHp000y1KLqiJcwRKnQeACLcB\/s1600\/wow.gif\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"><img border=\"0\" height=\"262\" src=\"https:\/\/4.bp.blogspot.com\/-zfaLCLsVE7Q\/WDeYoP1HqzI\/AAAAAAAAEcI\/Bpxx9lh2f3wWbHp000y1KLqiJcwRKnQeACLcB\/s640\/wow.gif\" width=\"640\" \/><\/a><\/div><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\"><br \/><\/span><span style=\"font-family: &quot;Trebuchet MS&quot;,sans-serif;\">&nbsp;<\/span>","protected":false},"excerpt":{"rendered":"<p>&#8211;Originally published at Programming and Hobbies Validated user inputEn esta publicaci\u00f3n los mostrar\u00e9 un ejemplo bastante sencillo para comprobar que la informaci\u00f3n proporcionada por el usuario es v\u00e1lida.Lo primero que debemos hacer es escribir un while true para generar un loop y \u00e9ste pueda repetirse hasta recibir un dato v\u00e1lido y despu\u00e9s debemos escribir una &hellip; <a href=\"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/programming-and-hobbies-2016-11-24-195000\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Programming and Hobbies 2016-11-24 19:50:00<\/span><\/a><\/p>\n","protected":false},"author":23,"featured_media":39331,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[],"class_list":["post-39330","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogs","category-syndicated"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/39330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/users\/23"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/comments?post=39330"}],"version-history":[{"count":4,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/39330\/revisions"}],"predecessor-version":[{"id":40114,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/39330\/revisions\/40114"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/media\/39331"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/media?parent=39330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/categories?post=39330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/tags?post=39330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}