182days

Enum Example

May 10th, 2016
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. #enum example
  2. #takes user input of month number and returns full month name
  3.  
  4. choice = input("Enter the name of a month in the year")
  5. from enum import Enum
  6. class Months(Enum):
  7.     January = 1
  8.     February = 2
  9.     March = 3
  10.     April = 4
  11.     May = 5
  12.     June = 6
  13.     July = 7
  14.     August = 8
  15.     September = 9
  16.     October = 10
  17.     November = 11
  18.     December = 12
  19.  
  20. print("You input",(choice))
  21. print Months.choice
Advertisement
Add Comment
Please, Sign In to add comment