forked from MIT-Emerging-Talent/ET6-practice-code-review
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
Module for the Voting age challenge. | ||
Contents: | ||
- Contextual code for names and a list to refer back to | ||
- Code that can refer back to minimum age and name list and produce an output base on name selection | ||
Created on 2025-01-03 | ||
Author: Adolfo Fumero | ||
""" | ||
|
||
min_age = 18 # this states the minimum age for voting | ||
|
||
participants = { | ||
'Jackson': {'age': 18}, | ||
'Bob': {'age': 40}, | ||
'Charlotte': {'age': 17}, | ||
'Marley': {'age': 28}, | ||
'Erica':{'age': 6}, | ||
} | ||
|
||
def check_voting_age(person): | ||
""" | ||
General: | ||
This function's goal is to check the age of the participants and if they are equal or above the minimum voting age based on input of name | ||
It pulls name and age from the Participants list and provides a Boolean output | ||
Parameters: | ||
Name: Correct name from Participants list | ||
Name list: Jackson , Bob, Charlotte, Marley, Erica | ||
Raises: | ||
If an invalid name is written, it will provide a "Participant not found." Output | ||
Correct capitalization is required, otherwise "Participant not found" Error will be raised | ||
""" | ||
return person['age'] >= min_age | ||
|
||
# Ask for the name input | ||
name = input("Enter the participant's name (Jackson, Bob, Charlotte, Marley, Erica): ") | ||
|
||
# Check if the name exists in the participants dictionary | ||
if name in participants: | ||
result = check_voting_age(participants[name]) | ||
print(f"Can {name} vote?: {result}") | ||
else: | ||
print("Participant not found.") |