To begin with, never use pre-defined constants like dict
as variable names as @Amadan pointed out, also ['a', 'b', 'c']
is a list
, and not a dictionary
, (which is a container to hold key-value pairs e.g. {"a":"b"}
.
Also you would want to check for ==
since you want the list to be concatenated to a string, and not is
, since is
checks if two object refers to the same location of memory as @TomaszBartkowiak pointed out , like below
In [21]: a = 1
In [22]: b = a
In [23]: a is b
Out[23]: True
In [24]: li = ['a', 'b', 'c']
In [25]: s = ' '.join(li)
In [26]: s is li
Out[26]: False
Hence the code will change to
def test_strings_concatenation():
#Define list and concatenate it
li = ['a', 'b', 'c']
li_as_string = " ".join(li)
expected = 'a b c'
#Check for string equality
assert li_as_string == expected
test_strings_concatenation()