Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor exercise #17

Open
fiumef opened this issue Mar 15, 2023 · 0 comments
Open

Refactor exercise #17

fiumef opened this issue Mar 15, 2023 · 0 comments

Comments

@fiumef
Copy link

fiumef commented Mar 15, 2023

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 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant