Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 367 Bytes

refactor_1.md

File metadata and controls

18 lines (13 loc) · 367 Bytes

Refactor 01

Refactor the following code

from collections import namedtuple

Mushroom = namedtuple('Mushroom', ['name', 'poisonous'])

mushrooms = [Mushroom('Portabello', False), Mushroom('Oyster', False),
             Mushroom('Death Cap', True)]
i = 0

for mushroom in mushrooms:
    i += 1
    name = mushroom.name
    print('%d:"%s"'%(i, name))