You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I understand, refactoring means, to write the code in a manner to be more readable and more compact.
I don't understand, first why you needed the namedtuple function from collection, second, why isn't the loop like this:
As I understand, refactoring means, to write the code in a manner to be more readable and more compact.
I don't understand, first why you needed the namedtuple function from collection, second, why isn't the loop like this:
from collections import namedtuple
Mushroom = namedtuple('Mushroom', ['name', 'poisonous'])
mushrooms = [Mushroom('Portabello', False), Mushroom('Oyster', False),
Mushroom('Death Cap', True)]
for x, i in enumerate(mushrooms):
print(x, i[0])
Also, why did you keep the counter i += 1?
The first value of enumerate, counts already
Thank you !
The text was updated successfully, but these errors were encountered: