Created
March 23, 2021 23:11
-
-
Save AnisahTiaraPratiwi/80c52965f5f82ac2d5a1943d655a1220 to your computer and use it in GitHub Desktop.
Complete the code to iterate through the keys and values of the car_prices dictionary, printing out some information about each one.
This file contains hidden or 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
def car_listing(car_prices): | |
result = "" | |
for cars in car_prices: | |
result += "{} costs {} dollars".format(cars, car_prices[cars]) + "\n" | |
return result | |
print(car_listing({"Kia Soul":19000, "Lamborghini Diablo":55000, "Ford Fiesta":13000, "Toyota Prius":24000})) |
def car_listing(car_prices):
result = ""
for make, price in car_prices.items():
result += "{} costs {} dollars".format(make,price) + "\n"
return result
print(car_listing({"Kia Soul":19000, "Lamborghini Diablo":55000, "Ford Fiesta":13000, "Toyota Prius":24000}))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output:
Kia Soul costs 19000 dollars
Lamborghini Diablo costs 55000 dollars
Ford Fiesta costs 13000 dollars
Toyota Prius costs 24000 dollars