-4
""" https://www.interviewcake.com/question/python/merge-sorted-arrays """ 
import unittest 

def merge_sorted_arrays(first, second):     
    # setup our merged list    
    merged_list_size = len(first) + len(second)     
    merged_list = [None] * merged_list_size 

What is the meaning of merged_list=[None]*merged_list_size? What does [None] stands for?

bphi
  • 3,115
  • 3
  • 23
  • 36
  • What happened when you ran that line of code? What part don't you understand? – Prune Mar 23 '18 at 17:13
  • 1
    You can refer this [answer](https://stackoverflow.com/a/24557558/6699447) which explain this in detail. It clearly explains when you should use this, and when you shouldn't – Abdul Niyas P M Mar 23 '18 at 17:23

2 Answers2

1

This will create a list with merged_list_size number of None elements.

Say merged_list_size was 3...

>>> merged_list=[None]*3
>>> print merged_list
[None, None, None]

The result is a list with 3 elements all of the value None

edit: when coming across things like this that you don't understand I would always test before looking for help. I personally always open a terminal and run the python command prompt to test out little things like this.

zerocool
  • 308
  • 1
  • 10
0

It does create a list of size merged_list_size whose elements are None. None is a built-in constant which represents the absence of a value.

Fore more info about built-in constants: https://docs.python.org/2/library/constants.html

Gonzalo Donoso
  • 657
  • 1
  • 6
  • 17