Python Tutorial part3
Hi, welcome to the Python Tutorial part3. In this lesson I am going to teach you the Inputs and Lists in Python. Before we start, if you have no knowledge about the Python programming language, I suggest you to read the previous parts.
Firs thing that we learn in Python Tutorial part3 is Inputs. Input is data that you take or receive from the user, you can ask a question or write something in input.
You use this function by typing the “input(“your question or demand”)”
. For instance, I asked the age of the user and demanded them to insert a number in the program. As you can see, when I run the program, the program asked me about my age and then demanded me to insert number.
Lists are one of the most useful things in Python and I decided to teach it in Python tutorial part3, The sooner you learn it, the better you get with it. Therefore lets not west anytime, Lists are the containers of our data (I will explain it more in the example).
You can create it by using “” and putting the values inside of it.
You probably got confused, lets make a list. First choose a value for example I have used “erfan_list” for my list, then type your list’s values “erfan_list = [“name”, “age”, “number”, 23, False]” you can put string, number or Boolean into the list.(like the picture down below)
We can create a list, that is awesome!!! But how to change the value of list and order of it or insert something into the list?
erfan_list = “not number”: changes the value index 1 (number) to “not number”.
erfan_list.sort(): sort the list by alphabet order
erfan_list.insert(2, “Mustang”): will insert the “Mustang” in index 2.
erfan_list.pop(): removes the last value of the list.
these are some of the basic things that comes handy for you, if you want to learn more stay toned for my future tutorials.
Share This Article on social media
this blog is written by Erfan Samadi
I hope you enjoyed! feel free to leave comment.