Completed 6-5 Rivers

This commit is contained in:
cheeks 2025-01-27 14:13:15 -05:00
parent 90423f2605
commit 110efb5eea

26
Chapter_06/6-05_rivers.py Normal file
View File

@ -0,0 +1,26 @@
# Exercise 6-5 Rivers
# Learning Objective: Use a loop on a dictionary using:
# A.) Both Kay and Value
# B.) Just Keys
# C.) Just Values
rivers = {'nile': 'egypt', 'mississippi': 'united states', 'volga': 'russia',}
# A. Both Key and Value:
for river, country in rivers.items():
print(f"\nThe {river.title()} runs through {country.title()}.")
print("\n-----------------------------------")
#B. Just Key:
for river in rivers.keys():
print(f"\nWe have the {river.title()} river in this dictionary.")
print("\n-----------------------------------")
#C. Just Values:
for country in rivers.values():
print(f"\nWe have the country {country.title()}, in this dictionary.")
print("\n-----------------------------------")