I am trying to complete a beginner assignment that entails referencing elements in tuples in a list that uses for loops and conditionals to output one of two types of strings depending on the values in the tuples.
Using a for loop and an if statement, go through vacc_counties and print out a message for those counties that have a higher than 30% vaccination rate.
Add another loop that prints out a message for every county, but prints different messages if the rate is above or below 30.
Example:
Benton County is doing ok, with a rate of 41.4%
Fulton County is doing less ok, with a rate of 22.1%
Here is the list of tuples followed by my own code:
vacc_counties = [('Pulaski', 42.7), ('Benton', 41.4), ('Fulton', 22.1), ('Miller', 9.6),
('Mississippi', 29.4), ('Scotty County', 28.1)]
for tuple in vacc_counties:
for element in tuple:
if [1] < 30:
print(f"{vacc_counties[0]}is doing ok, with a rate of" [1]"%")
else [1] n > 30:
print(f"{vacc_counties[0]}is doing ok, with a rate of" [1]"%")