python에서 switch문 쓰기
2015. 7. 23. 10:41ㆍProgramming/python
Python에서는 switch문이나 case문이 존재하지 않는다.
그래서 python에서는 switch문과 비슷한 동작을 할 수 있도록 dictionary를 이용해서 아래와 같이 구현한다.
switch_map = {
'APPLE' : 1,
'BANANA' : 2,
'TOMATO' : 3
}
print switch_map['APPLE']
print switch_map['BANANA']