1 00:00:00,000 --> 00:00:05,000 In this lesson, I'm going to show you how you can ask the user to write something, 2 00:00:05,001 --> 00:00:09,000 which you can then use and store inside a variable. 3 00:00:09,001 --> 00:00:13,000 This will add more interactiveness to the program and makes it more dynamic. 4 00:00:13,001 --> 00:00:17,000 It's going to be great for your Python learning path. 5 00:00:17,001 --> 00:00:20,489 So if you want to ask the user to write something, 6 00:00:20,501 --> 00:00:24,000 you just have to use the input function like this. 7 00:00:24,001 --> 00:00:26,000 Open and close the parentheses. 8 00:00:26,001 --> 00:00:32,000 So I press enter and now as you can see the cursor is on the next line 9 00:00:32,001 --> 00:00:35,000 and is actually waiting for you to write something. 10 00:00:35,001 --> 00:00:37,000 So let's write test. 11 00:00:37,001 --> 00:00:41,000 Okay and you can see now the result. 12 00:00:41,001 --> 00:00:44,000 So what is going into the input function is test. 13 00:00:44,001 --> 00:00:46,000 Input. 14 00:00:46,001 --> 00:00:50,000 If you want, you can also ask the user. 15 00:00:50,001 --> 00:00:52,000 So you can ask a question. 16 00:00:52,001 --> 00:00:55,000 If you just write input, it's going to wait for an input. 17 00:00:55,001 --> 00:00:59,000 You can also give an information of what you want. 18 00:00:59,001 --> 00:01:01,000 Let's say choose a number. 19 00:01:01,001 --> 00:01:06,000 So now I have choose a number and I can choose a number. 20 00:01:06,001 --> 00:01:07,000 Let's say 3. 21 00:01:07,001 --> 00:01:11,000 I write 3 and then it is evaluated to 3. 22 00:01:11,001 --> 00:01:14,000 So we can actually make it better. 23 00:01:14,001 --> 00:01:17,000 Just put a column like this in a space. 24 00:01:17,001 --> 00:01:21,000 Okay to make it look better. 25 00:01:21,001 --> 00:01:26,000 And as you can see here, if you give a string or if you give a number, 26 00:01:26,001 --> 00:01:30,000 the result is always going to be a string with the input function. 27 00:01:30,001 --> 00:01:33,000 Okay if I type input. 28 00:01:33,001 --> 00:01:35,000 Let's say choose a number. 29 00:01:35,001 --> 00:01:42,000 So here as you can see I'm using a Python function inside another Python function. 30 00:01:42,001 --> 00:01:45,706 In that case what is going to happen, the more 31 00:01:45,718 --> 00:01:50,000 nested function is actually going to be called first. 32 00:01:50,001 --> 00:01:54,000 So input is going to be called so it will print choose a number. 33 00:01:54,001 --> 00:01:59,000 And then this, the result of the input function is going to go in the type function 34 00:01:59,001 --> 00:02:03,000 which will evaluate the type of what you gave. 35 00:02:03,001 --> 00:02:07,000 So I'm going to put 3 and you can see now we have type string. 36 00:02:07,001 --> 00:02:11,000 Okay that's an important thing to know is that whenever you use input, 37 00:02:11,001 --> 00:02:15,000 the result you are going to get will be of type string. 38 00:02:15,001 --> 00:02:19,000 And well what you can do is, I can do, so let's do input. 39 00:02:20,000 --> 00:02:23,000 And I can do for example a is equal to input. 40 00:02:23,001 --> 00:02:26,000 Okay so I choose a number let's say 67. 41 00:02:26,001 --> 00:02:32,000 And now the result of the input will go to the variable a. 42 00:02:32,001 --> 00:02:36,000 So if I do a, I get 67 which is of course a string here. 43 00:02:36,001 --> 00:02:42,000 But then from that you can use the input of the user in your program.