1. Learn
  2. /
  3. Courses
  4. /
  5. Python for MATLAB Users

Exercise

Counting different types of aircraft

For this exercise, you have a dictionary, aircraft_engines that contains the engine type of a number of popular commercial airplanes. You want to count how many airplanes of each engine type exist in this dataset. Use your Python control flow skills by creating a for loop that contains an if/else statement that adds 1 to the counts variable for every new engine type.

Instructions

100 XP
  • Write a for loop that goes through each key:value pair of airplane_types.
  • On each iteration, "The x airplane has y engines." should be printed out, where x is the name of the airplane and y is the type of engine.
  • For each iteration, increment the values of the engine_type key in the counts dictionary.
  • Finally, print the "counts" dictionary