Need help with printing key-value(s) from a Dictionary

Ok, so my exercise is to create a dictionary of four river and their locations in the world, then print a message indicating that “The ‘x’ river runs through ‘y’.”

Dictionary:

rivers = {
	'nile': 'egypt',
	'mississippi': 'usa',
	'danube': 'germany',
	'yangtze': 'china',
	}

So, I know how to pull either the key or the value…but not both at the same time. I’m trying to use a for loop to go through the list and print the message for each key-value pair.

for river in rivers:
	print("The " rivers.keys().title() + " runs through " + 
		rivers.values.title() + ".")

I’m fairly confident that I can’t “stack” the .keys().title() (same with values), so I’m stuck as to how to get everything contained in the loop.

So, again, I’m unsure how to call both key and value in the same loop and satisfy the exercise.

Thanks in advance!

Python dictionaries have items(), keys() and values() method to iterate through contents…

In this for loop, river variable stores values of keys in dictionary (i.e. ‘nile’, ‘mississipi’)

therefore in this loop you can get name of river with river and it’s location with rivers[river]… like above statement

river.title() + " runs through " + rivers[river].title() + "."
f"{river.title()} runs through {rivers[river].title()}."    # using f-strings

Additionally, you can use above mentioned inbuilt methods,
Learn more about them here