Closed bnmnetp closed 3 years ago
I was just going to report this bug! Perhaps you got it from one of my students. Here's some documentation of a specific case which may help with debugging.
.. parsonsprob:: NestedData_Exercises_q17_5_2
:prim_comp: NEST02
:supp_comp: OP04, OP05, STR01, DICT01, DICT02, DICT03, ITER02, COND0
:difficulty: 3.5
Assume the following variable has been declared:
.. code-block:: python
pokemon = [
{
'rattatas': 15,
'eevees': 2,
'ditto': 1,
'magikarps': 3,
'zubats': 8,
'pidgey': 12
},
{
'rattatas': 25,
'eevees': 1,
'magikarps': 7,
'zubats': 3,
'pidgey': 15
},
{
'rattatas':10,
'eevees': 3,
'ditto': 2,
'magikarps': 2,
'zubats': 3,
'pidgey': 20
},
{
'rattatas': 17,
'eevees': 1,
'magikarps': 9,
'zubats': 12,
'pidgey': 14
}
]
|
| Arrange the following lines of code so that they print out exactly:
| ``total rattatas: 67``
| ``total dittos: 3``
| ``total pidgeys: 61``
|
| **Note:** You may not need to use all blocks of code.
| **Note:** Be sure to indent blocks as needed by dragging them to the
correct indentation level.
-----
r = 0
d = 0
p = 0
=====
for trainer in pokemon:
=====
r += trainer['rattatas']
p += trainer['pidgey']
if "ditto" in trainer:
=====
r = trainer['rattatas'] #distractor
p = trainer['pidgey']
if "ditto" in trainer:
=====
d += trainer['ditto']
=====
d = trainer['ditto'] #distractor
=====
print('total rattatas:', r)
print('total dittos:', d)
print('total pidgeys:', p)
fixed in 5.6.2
I'm pretty sure this is due to a
.. code-block
or::
or whatever geneating a<pre>
tag in the instructions. Then the rendering code goes looking for a pre tag to make the blocks from and gets confused.Should be easy to fix by providing an identifier or class for the pre tag that really contains the blocks.