At the end of this lesson, you will be able to:
# Created by: Mr. Atkinson
# Created on: Apr 16, 2019
# Created for: ICS3U
# This program is an example of enumerated types
from enum import Enum
class Planets(Enum):
Mercury = 1
Venus = 2
Earth = 3
Mars = 4
Jupiter = 5
Saturn = 6
Uranus = 7
Neptune = 8
print(len(Planets))
print(Planets.Earth.value)
print(Planets.Earth.name)
planet_selected = 'Pluto'
if isinstance(planet_selected, Planets):
print(planet_selected + ' is a valid planet')
else:
print('That is not a planet')
planet_selected = int(input('Enter the planet # you would like to visit: '))
print(Planets(planet_selected).name)