educative.io

Use of none keyword

Screenshot 2022-04-26 153608
in the course, a question where I have to reverse a list, I cannot understand the use of None keyword and why it is multiplied by length of the passed array


Type your question above this line.

Course: https://www.educative.io/collection/10370001/5765097389555712
Lesson: https://www.educative.io/collection/page/10370001/5765097389555712/5671811639410688

Hello @Manan_Jain

None is a keyword in Python to define Null objects or variables. In this case, we have created a list new_list of length length and initialized all values to None. For instance, if the length of the list was 3, then the new_list will be [None, None, None]. This syntax of multiplying is just a way in Python to initialize a list of certain length with some default values.

Hope this helps!

1 Like

YUP! Thanks, @Muhammad_Raahim_Khan