<\/p>\n
<\/p>\n
Programs in Python are able to receive input coming from the user. The function able to do this is the input<\/em> function. When this function is called, the program stops and waits for the user to type something. The program continues when the user press return or enter. <\/span><\/p>\n Example: <\/span><\/p>\n <\/p>\n <\/p>\n <\/p>\n After input(), the Python shell received the text that I wrote and that piece of text was assigned to the variable text, so when I print the text variable I am able to read the same text that I typed. <\/span><\/p>\n Also, you can prompt to the user what to input, per example: <\/span><\/p>\n <\/p>\n <\/p>\n <\/p>\n If you want to see the input in a new line, use the sequence n at the end of the prompt. Example:<\/span><\/p>\n <\/p>\n <\/p>\n Can you see the difference? In my opinion it looks nicer. <\/span><\/p>\n <\/p>\n <\/p>\n If you expect the user to type a certain type, you can indicate that in your code. Example:<\/span><\/p>\n <\/p>\n <\/p>\n <\/p>\n But if I type something different than an integer I get an error message: <\/span><\/p>\n <\/p>\n <\/p>\n <\/p>\n So, this is basically how you handle basic input from the user. <\/span><\/p>\n #Mastery<\/a>28<\/span><\/p>\n \u00a0<\/p>\n \u00a0<\/p>\n \u00a0<\/p>\n \u00a0<\/p>\n \u00a0<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":" <\/p>\n <\/p>\n Normal 21<\/p>\n false ES-MX <\/p>\n <\/p>\n \/* Style Definitions *\/ Programs in Python are able to receive input coming from the user. The function able to do this is the input<\/em> function. When this function is called, the program stops and waits for the user to type something. The program continues when the user press return or enter. <\/span><\/p>\n Example: <\/span><\/p>\n<\/p>\n <\/p>\n <\/p>\n Normal 21<\/p>\n false ES-MX <\/p>\n <\/p>\n \/* Style Definitions *\/ After input(), the Python shell received the text that I wrote and that piece of text was assigned to the variable text, so when I print the text variable I am able to read the same text that I typed. <\/span><\/p>\n Also, you can prompt to the user what to input, per example: <\/span><\/p>\n<\/p>\n <\/p>\n <\/p>\n Normal 21<\/p>\n false ES-MX <\/p>\n <\/p>\n \/* Style Definitions *\/ If you want to see the input in a new line, use the sequence n at the end of the prompt. Example:<\/span><\/p>\n<\/p>\n <\/p>\n <\/p>\n Normal 21<\/p>\n false ES-MX <\/p>\n <\/p>\n \/* Style Definitions *\/ Can you see the difference? In my opinion it looks nicer. <\/span><\/p>\n <\/p>\n <\/p>\n Normal 21<\/p>\n false ES-MX <\/p>\n <\/p>\n \/* Style Definitions *\/ If you expect the user to type a certain type, you can indicate that in your code. Example:<\/span><\/p>\n<\/p>\n <\/p>\n <\/p>\n Normal 21<\/p>\n false ES-MX <\/p>\n <\/p>\n \/* Style Definitions *\/ But if I type something different than an integer I get an error message: <\/span><\/p>\n<\/p>\n <\/p>\n <\/p>\n Normal 21<\/p>\n false ES-MX <\/p>\n <\/p>\n \/* Style Definitions *\/ So, this is basically how you handle basic input from the user. <\/span><\/p>\n #Mastery<\/a>28<\/span><\/p>\n <\/p>\n <\/p>\n <\/p>\n <\/p>\n <\/p>\n<\/div>\n
\n 0<\/p>\n
\n false
\n false<\/p>\n
\n X-NONE
\n X-NONE<\/p>\n
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n
\n 0<\/p>\n
\n false
\n false<\/p>\n
\n X-NONE
\n X-NONE<\/p>\n
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n
\n 0<\/p>\n
\n false
\n false<\/p>\n
\n X-NONE
\n X-NONE<\/p>\n
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n
\n 0<\/p>\n
\n false
\n false<\/p>\n
\n X-NONE
\n X-NONE<\/p>\n
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n
\n 0<\/p>\n
\n false
\n false<\/p>\n
\n X-NONE
\n X-NONE<\/p>\n
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n
\n 0<\/p>\n
\n false
\n false<\/p>\n
\n X-NONE
\n X-NONE<\/p>\n
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n
\n 0<\/p>\n
\n false
\n false<\/p>\n
\n X-NONE
\n X-NONE<\/p>\n
\n table.MsoNormalTable
\n\t{mso-style-name:”Tabla normal”;
\n\tmso-tstyle-rowband-size:0;
\n\tmso-tstyle-colband-size:0;
\n\tmso-style-noshow:yes;
\n\tmso-style-priority:99;
\n\tmso-style-parent:””;
\n\tmso-padding-alt:0cm 5.4pt 0cm 5.4pt;
\n\tmso-para-margin-top:0cm;
\n\tmso-para-margin-right:0cm;
\n\tmso-para-margin-bottom:8.0pt;
\n\tmso-para-margin-left:0cm;
\n\tline-height:107%;
\n\tmso-pagination:widow-orphan;
\n\tfont-size:11.0pt;
\n\tfont-family:”Calibri”,sans-serif;
\n\tmso-ascii-font-family:Calibri;
\n\tmso-ascii-theme-font:minor-latin;
\n\tmso-hansi-font-family:Calibri;
\n\tmso-hansi-theme-font:minor-latin;
\n\tmso-fareast-language:EN-US;}<\/p>\n