I cannot get the following assert statement to work:
assert(data[5] == {
'tone': ['line', 'five', 'Test', 'one', '.'],
'ttwo': ['line', 'five', 'Test', 'two', '.'],
'tline': [3]
})
My understanding is that it is testing for that the data indexed at position 5 in each of the lists ("tone", "ttwo", and "tline"), but is "data" meant to be a dictionary? It has curly brackets, however, if it is a dictionary that would make "tone", "ttwo", and "tline" keys, not lists, which doesn't make sense to me.
Alternatively, is data
meant to be a list containing further lists (tone
, ttwo
, and tline
) which themselves contain further lists of strings or numbers?
I think I have the data itself in the right format for tone
, ttwo
and tline
(see below); I just can't figure out how to put them into "data" to make this assert statement work.
tone = ['line', 'five', 'Test', 'one', '.']
ttwo = ['line', 'five', 'Test', 'two', '.']
tline = 3
I've tried to solve this every way I know how (setting data
as a list/tuple/dictionary) and I've had no luck. I have looked, but I can't find a similar question with the same type of data structures or assert statement.
Your understanding is a bit off. This assert
checks that the 6th element of data
is a directory with those values. The assignment to data to pass this statement might look like this:
data = [0, 1, 2, 3, 4,
{
'tone': tone,
'ttwo': ttwo,
'tline': tline}]
Now the assertion passes.