Skip to content

Fix loop var in first code sample #8

Description

@zstumgoren

election_results.py includes a loop that overwrites a previously declared variable. Script still works but it's a little too confusing for teaching purposes. Change needs to be made below and should be carried over to all elex dirs, branches and tutorial pages to ensure consistency:

for race_key, cand_results in results.items():
    all_votes = 0 
    cands = []
   # NOTE: below "results" var should be renamed to "row"
    for cand_key, results in cand_results.items():
        # Populate a new candidate dict using one set of county results
        cand = { 
            'first_name': results[0]['first_name'],
            'last_name': results[0]['last_name'],
            'party': results[0]['party'],
            'winner': '', 
        }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions