#-*- coding:utf-8 -*- 
"""
ÃƒÂ¤Ã‚Â¸Ã¢â‚¬Â¹ÃƒÂ©Ã¯Â¿Â½Ã‚Â¢ÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ¦Ã¢â‚¬â€œÃ¢â‚¬Â¡ÃƒÂ¤Ã‚Â»Ã‚Â¶ÃƒÂ¥Ã‚Â°Ã¢â‚¬Â ÃƒÂ¤Ã‚Â¼Ã…Â¡ÃƒÂ¤Ã‚Â»Ã…Â½csvÃƒÂ¦Ã¢â‚¬â€œÃ¢â‚¬Â¡ÃƒÂ¤Ã‚Â»Ã‚Â¶ÃƒÂ¤Ã‚Â¸Ã‚Â­ÃƒÂ¨Ã‚Â¯Ã‚Â»ÃƒÂ¥Ã¯Â¿Â½Ã¢â‚¬â€œÃƒÂ¨Ã‚Â¯Ã‚Â»ÃƒÂ¥Ã¯Â¿Â½Ã¢â‚¬â€œÃƒÂ§Ã…Â¸Ã‚Â­ÃƒÂ¤Ã‚Â¿Ã‚Â¡ÃƒÂ¤Ã‚Â¸Ã…Â½ÃƒÂ§Ã¢â‚¬ï¿½Ã‚ÂµÃƒÂ¨Ã‚Â¯Ã¯Â¿Â½ÃƒÂ¨Ã‚Â®Ã‚Â°ÃƒÂ¥Ã‚Â½Ã¢â‚¬Â¢ÃƒÂ¯Ã‚Â¼Ã…â€™
ÃƒÂ¤Ã‚Â½Ã‚Â ÃƒÂ¥Ã‚Â°Ã¢â‚¬Â ÃƒÂ¥Ã…â€œÃ‚Â¨ÃƒÂ¤Ã‚Â»Ã‚Â¥ÃƒÂ¥Ã¯Â¿Â½Ã…Â½ÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ¨Ã‚Â¯Ã‚Â¾ÃƒÂ§Ã‚Â¨Ã¢â‚¬Â¹ÃƒÂ¤Ã‚Â¸Ã‚Â­ÃƒÂ¤Ã‚ÂºÃ¢â‚¬Â ÃƒÂ¨Ã‚Â§Ã‚Â£ÃƒÂ¦Ã¢â‚¬ÂºÃ‚Â´ÃƒÂ¥Ã‚Â¤Ã…Â¡ÃƒÂ¦Ã…â€œÃ¢â‚¬Â°ÃƒÂ¥Ã¢â‚¬Â¦Ã‚Â³ÃƒÂ¨Ã‚Â¯Ã‚Â»ÃƒÂ¥Ã¯Â¿Â½Ã¢â‚¬â€œÃƒÂ¦Ã¢â‚¬â€œÃ¢â‚¬Â¡ÃƒÂ¤Ã‚Â»Ã‚Â¶ÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ§Ã…Â¸Ã‚Â¥ÃƒÂ¨Ã‚Â¯Ã¢â‚¬Â ÃƒÂ£Ã¢â€šÂ¬Ã¢â‚¬Å¡
"""
import csv
import re

with open('texts.csv', 'r') as f:
    reader = csv.reader(f)
    texts = list(reader)

with open('calls.csv', 'r') as f:
    reader = csv.reader(f)
    calls = list(reader)

"""
ÃƒÂ¤Ã‚Â»Ã‚Â»ÃƒÂ¥Ã…Â Ã‚Â¡3:
(080)ÃƒÂ¦Ã‹Å“Ã‚Â¯ÃƒÂ§Ã¯Â¿Â½Ã‚Â­ÃƒÂ¥Ã…Â Ã‚Â ÃƒÂ§Ã‚Â½Ã¢â‚¬â€�ÃƒÂ¥Ã‚Â°Ã¢â‚¬ï¿½ÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ¥Ã¢â‚¬ÂºÃ‚ÂºÃƒÂ¥Ã‚Â®Ã…Â¡ÃƒÂ§Ã¢â‚¬ï¿½Ã‚ÂµÃƒÂ¨Ã‚Â¯Ã¯Â¿Â½ÃƒÂ¥Ã…â€™Ã‚ÂºÃƒÂ¥Ã¯Â¿Â½Ã‚Â·ÃƒÂ£Ã¢â€šÂ¬Ã¢â‚¬Å¡
ÃƒÂ¥Ã¢â‚¬ÂºÃ‚ÂºÃƒÂ¥Ã‚Â®Ã…Â¡ÃƒÂ§Ã¢â‚¬ï¿½Ã‚ÂµÃƒÂ¨Ã‚Â¯Ã¯Â¿Â½ÃƒÂ¥Ã¯Â¿Â½Ã‚Â·ÃƒÂ§Ã‚Â Ã¯Â¿Â½ÃƒÂ¥Ã…â€™Ã¢â‚¬Â¦ÃƒÂ¥Ã¯Â¿Â½Ã‚Â«ÃƒÂ¦Ã¢â‚¬Â¹Ã‚Â¬ÃƒÂ¥Ã¯Â¿Â½Ã‚Â·ÃƒÂ¯Ã‚Â¼Ã…â€™
ÃƒÂ¦Ã¢â‚¬Â°Ã¢â€šÂ¬ÃƒÂ¤Ã‚Â»Ã‚Â¥ÃƒÂ§Ã¯Â¿Â½Ã‚Â­ÃƒÂ¥Ã…Â Ã‚Â ÃƒÂ§Ã‚Â½Ã¢â‚¬â€�ÃƒÂ¥Ã‚Â°Ã¢â‚¬ï¿½ÃƒÂ¥Ã…â€œÃ‚Â°ÃƒÂ¥Ã…â€™Ã‚ÂºÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ§Ã¢â‚¬ï¿½Ã‚ÂµÃƒÂ¨Ã‚Â¯Ã¯Â¿Â½ÃƒÂ¥Ã¯Â¿Â½Ã‚Â·ÃƒÂ§Ã‚Â Ã¯Â¿Â½ÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ¦Ã‚Â Ã‚Â¼ÃƒÂ¥Ã‚Â¼Ã¯Â¿Â½ÃƒÂ¤Ã‚Â¸Ã‚Âº(080)xxxxxxxÃƒÂ£Ã¢â€šÂ¬Ã¢â‚¬Å¡

ÃƒÂ§Ã‚Â¬Ã‚Â¬ÃƒÂ¤Ã‚Â¸Ã¢â€šÂ¬ÃƒÂ©Ã†â€™Ã‚Â¨ÃƒÂ¥Ã‹â€ Ã¢â‚¬Â : ÃƒÂ¦Ã¢â‚¬Â°Ã‚Â¾ÃƒÂ¥Ã¢â‚¬Â¡Ã‚ÂºÃƒÂ¨Ã‚Â¢Ã‚Â«ÃƒÂ§Ã¯Â¿Â½Ã‚Â­ÃƒÂ¥Ã…Â Ã‚Â ÃƒÂ§Ã‚Â½Ã¢â‚¬â€�ÃƒÂ¥Ã‚Â°Ã¢â‚¬ï¿½ÃƒÂ¥Ã…â€œÃ‚Â°ÃƒÂ¥Ã…â€™Ã‚ÂºÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ¥Ã¢â‚¬ÂºÃ‚ÂºÃƒÂ¥Ã‚Â®Ã…Â¡ÃƒÂ§Ã¢â‚¬ï¿½Ã‚ÂµÃƒÂ¨Ã‚Â¯Ã¯Â¿Â½ÃƒÂ¦Ã¢â‚¬Â°Ã¢â€šÂ¬ÃƒÂ¦Ã¢â‚¬Â¹Ã‚Â¨ÃƒÂ¦Ã¢â‚¬Â°Ã¢â‚¬Å“ÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ¦Ã¢â‚¬Â°Ã¢â€šÂ¬ÃƒÂ¦Ã…â€œÃ¢â‚¬Â°ÃƒÂ§Ã¢â‚¬ï¿½Ã‚ÂµÃƒÂ¨Ã‚Â¯Ã¯Â¿Â½ÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ¥Ã…â€™Ã‚ÂºÃƒÂ¥Ã¯Â¿Â½Ã‚Â·ÃƒÂ¥Ã¢â‚¬â„¢Ã…â€™ÃƒÂ§Ã‚Â§Ã‚Â»ÃƒÂ¥Ã…Â Ã‚Â¨ÃƒÂ¥Ã¢â‚¬Â°Ã¯Â¿Â½ÃƒÂ§Ã‚Â¼Ã¢â€šÂ¬ÃƒÂ¯Ã‚Â¼Ã‹â€ ÃƒÂ¤Ã‚Â»Ã‚Â£ÃƒÂ¥Ã¯Â¿Â½Ã‚Â·ÃƒÂ¯Ã‚Â¼Ã¢â‚¬Â°ÃƒÂ£Ã¢â€šÂ¬Ã¢â‚¬Å¡
 - ÃƒÂ¥Ã¢â‚¬ÂºÃ‚ÂºÃƒÂ¥Ã‚Â®Ã…Â¡ÃƒÂ§Ã¢â‚¬ï¿½Ã‚ÂµÃƒÂ¨Ã‚Â¯Ã¯Â¿Â½ÃƒÂ¤Ã‚Â»Ã‚Â¥ÃƒÂ¦Ã¢â‚¬Â¹Ã‚Â¬ÃƒÂ¥Ã¯Â¿Â½Ã‚Â·ÃƒÂ¥Ã¢â‚¬Â Ã¢â‚¬Â¦ÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ¥Ã…â€™Ã‚ÂºÃƒÂ¥Ã¯Â¿Â½Ã‚Â·ÃƒÂ¥Ã‚Â¼Ã¢â€šÂ¬ÃƒÂ¥Ã‚Â§Ã¢â‚¬Â¹ÃƒÂ£Ã¢â€šÂ¬Ã¢â‚¬Å¡ÃƒÂ¥Ã…â€™Ã‚ÂºÃƒÂ¥Ã¯Â¿Â½Ã‚Â·ÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ©Ã¢â‚¬Â¢Ã‚Â¿ÃƒÂ¥Ã‚ÂºÃ‚Â¦ÃƒÂ¤Ã‚Â¸Ã¯Â¿Â½ÃƒÂ¥Ã‚Â®Ã…Â¡ÃƒÂ¯Ã‚Â¼Ã…â€™ÃƒÂ¤Ã‚Â½Ã¢â‚¬Â ÃƒÂ¦Ã¢â€šÂ¬Ã‚Â»ÃƒÂ¦Ã‹Å“Ã‚Â¯ÃƒÂ¤Ã‚Â»Ã‚Â¥ 0 ÃƒÂ¦Ã¢â‚¬Â°Ã¢â‚¬Å“ÃƒÂ¥Ã‚Â¤Ã‚Â´ÃƒÂ£Ã¢â€šÂ¬Ã¢â‚¬Å¡
 - ÃƒÂ§Ã‚Â§Ã‚Â»ÃƒÂ¥Ã…Â Ã‚Â¨ÃƒÂ§Ã¢â‚¬ï¿½Ã‚ÂµÃƒÂ¨Ã‚Â¯Ã¯Â¿Â½ÃƒÂ¦Ã‚Â²Ã‚Â¡ÃƒÂ¦Ã…â€œÃ¢â‚¬Â°ÃƒÂ¦Ã¢â‚¬Â¹Ã‚Â¬ÃƒÂ¥Ã¯Â¿Â½Ã‚Â·ÃƒÂ¯Ã‚Â¼Ã…â€™ÃƒÂ¤Ã‚Â½Ã¢â‚¬Â ÃƒÂ¦Ã¢â‚¬Â¢Ã‚Â°ÃƒÂ¥Ã‚Â­Ã¢â‚¬â€�ÃƒÂ¤Ã‚Â¸Ã‚Â­ÃƒÂ©Ã¢â‚¬â€�Ã‚Â´ÃƒÂ¦Ã‚Â·Ã‚Â»ÃƒÂ¥Ã…Â Ã‚Â ÃƒÂ¤Ã‚ÂºÃ¢â‚¬Â 
   ÃƒÂ¤Ã‚Â¸Ã¢â€šÂ¬ÃƒÂ¤Ã‚Â¸Ã‚ÂªÃƒÂ§Ã‚Â©Ã‚ÂºÃƒÂ¦Ã‚Â Ã‚Â¼ÃƒÂ¯Ã‚Â¼Ã…â€™ÃƒÂ¤Ã‚Â»Ã‚Â¥ÃƒÂ¥Ã‚Â¢Ã…Â¾ÃƒÂ¥Ã…Â Ã‚Â ÃƒÂ¥Ã¯Â¿Â½Ã‚Â¯ÃƒÂ¨Ã‚Â¯Ã‚Â»ÃƒÂ¦Ã¢â€šÂ¬Ã‚Â§ÃƒÂ£Ã¢â€šÂ¬Ã¢â‚¬Å¡ÃƒÂ¤Ã‚Â¸Ã¢â€šÂ¬ÃƒÂ¤Ã‚Â¸Ã‚ÂªÃƒÂ§Ã‚Â§Ã‚Â»ÃƒÂ¥Ã…Â Ã‚Â¨ÃƒÂ§Ã¢â‚¬ï¿½Ã‚ÂµÃƒÂ¨Ã‚Â¯Ã¯Â¿Â½ÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ§Ã‚Â§Ã‚Â»ÃƒÂ¥Ã…Â Ã‚Â¨ÃƒÂ¥Ã¢â‚¬Â°Ã¯Â¿Â½ÃƒÂ§Ã‚Â¼Ã¢â€šÂ¬ÃƒÂ¦Ã…â€™Ã¢â‚¬Â¡ÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ¦Ã‹Å“Ã‚Â¯ÃƒÂ¤Ã‚Â»Ã¢â‚¬â€œÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ¥Ã¢â‚¬Â°Ã¯Â¿Â½ÃƒÂ¥Ã¢â‚¬ÂºÃ¢â‚¬ÂºÃƒÂ¤Ã‚Â¸Ã‚Âª
   ÃƒÂ¦Ã¢â‚¬Â¢Ã‚Â°ÃƒÂ¥Ã‚Â­Ã¢â‚¬â€�ÃƒÂ¯Ã‚Â¼Ã…â€™ÃƒÂ¥Ã‚Â¹Ã‚Â¶ÃƒÂ¤Ã‚Â¸Ã¢â‚¬ï¿½ÃƒÂ¤Ã‚Â»Ã‚Â¥7,8ÃƒÂ¦Ã‹â€ Ã¢â‚¬â€œ9ÃƒÂ¥Ã‚Â¼Ã¢â€šÂ¬ÃƒÂ¥Ã‚Â¤Ã‚Â´ÃƒÂ£Ã¢â€šÂ¬Ã¢â‚¬Å¡
 - ÃƒÂ§Ã¢â‚¬ï¿½Ã‚ÂµÃƒÂ¨Ã‚Â¯Ã¯Â¿Â½ÃƒÂ¤Ã‚Â¿Ã†â€™ÃƒÂ©Ã¢â‚¬ï¿½Ã¢â€šÂ¬ÃƒÂ¥Ã¢â‚¬ËœÃ‹Å“ÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ¥Ã¯Â¿Â½Ã‚Â·ÃƒÂ§Ã‚Â Ã¯Â¿Â½ÃƒÂ¦Ã‚Â²Ã‚Â¡ÃƒÂ¦Ã…â€œÃ¢â‚¬Â°ÃƒÂ¦Ã¢â‚¬Â¹Ã‚Â¬ÃƒÂ¥Ã¯Â¿Â½Ã‚Â·ÃƒÂ¦Ã‹â€ Ã¢â‚¬â€œÃƒÂ§Ã‚Â©Ã‚ÂºÃƒÂ¦Ã‚Â Ã‚Â¼ , ÃƒÂ¤Ã‚Â½Ã¢â‚¬Â ÃƒÂ¤Ã‚Â»Ã‚Â¥140ÃƒÂ¥Ã‚Â¼Ã¢â€šÂ¬ÃƒÂ¥Ã‚Â¤Ã‚Â´ÃƒÂ£Ã¢â€šÂ¬Ã¢â‚¬Å¡

ÃƒÂ¨Ã‚Â¾Ã¢â‚¬Å“ÃƒÂ¥Ã¢â‚¬Â¡Ã‚ÂºÃƒÂ¤Ã‚Â¿Ã‚Â¡ÃƒÂ¦Ã¯Â¿Â½Ã‚Â¯:
"The numbers called by people in Bangalore have codes:"
 <list of codes>
ÃƒÂ¤Ã‚Â»Ã‚Â£ÃƒÂ¥Ã¯Â¿Â½Ã‚Â·ÃƒÂ¤Ã‚Â¸Ã¯Â¿Â½ÃƒÂ¨Ã†â€™Ã‚Â½ÃƒÂ©Ã¢â‚¬Â¡Ã¯Â¿Â½ÃƒÂ¥Ã‚Â¤Ã¯Â¿Â½ÃƒÂ¯Ã‚Â¼Ã…â€™ÃƒÂ¦Ã‚Â¯Ã¯Â¿Â½ÃƒÂ¨Ã‚Â¡Ã…â€™ÃƒÂ¦Ã¢â‚¬Â°Ã¢â‚¬Å“ÃƒÂ¥Ã¯Â¿Â½Ã‚Â°ÃƒÂ¤Ã‚Â¸Ã¢â€šÂ¬ÃƒÂ¦Ã¯Â¿Â½Ã‚Â¡ÃƒÂ¯Ã‚Â¼Ã…â€™ÃƒÂ¦Ã…â€™Ã¢â‚¬Â°ÃƒÂ¥Ã‚Â­Ã¢â‚¬â€�ÃƒÂ¦Ã‚Â¯Ã¯Â¿Â½ÃƒÂ©Ã‚Â¡Ã‚ÂºÃƒÂ¥Ã‚ÂºÃ¯Â¿Â½ÃƒÂ¨Ã‚Â¾Ã¢â‚¬Å“ÃƒÂ¥Ã¢â‚¬Â¡Ã‚ÂºÃƒÂ£Ã¢â€šÂ¬Ã¢â‚¬Å¡

ÃƒÂ§Ã‚Â¬Ã‚Â¬ÃƒÂ¤Ã‚ÂºÃ…â€™ÃƒÂ©Ã†â€™Ã‚Â¨ÃƒÂ¥Ã‹â€ Ã¢â‚¬Â : ÃƒÂ§Ã¢â‚¬ï¿½Ã‚Â±ÃƒÂ§Ã¯Â¿Â½Ã‚Â­ÃƒÂ¥Ã…Â Ã‚Â ÃƒÂ§Ã‚Â½Ã¢â‚¬â€�ÃƒÂ¥Ã‚Â°Ã¢â‚¬ï¿½ÃƒÂ¥Ã¢â‚¬ÂºÃ‚ÂºÃƒÂ¨Ã‚Â¯Ã¯Â¿Â½ÃƒÂ¦Ã¢â‚¬Â°Ã¢â‚¬Å“ÃƒÂ¥Ã‚Â¾Ã¢â€šÂ¬ÃƒÂ§Ã¯Â¿Â½Ã‚Â­ÃƒÂ¥Ã…Â Ã‚Â ÃƒÂ§Ã‚Â½Ã¢â‚¬â€�ÃƒÂ¥Ã‚Â°Ã¢â‚¬ï¿½ÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ§Ã¢â‚¬ï¿½Ã‚ÂµÃƒÂ¨Ã‚Â¯Ã¯Â¿Â½ÃƒÂ¦Ã¢â‚¬Â°Ã¢â€šÂ¬ÃƒÂ¥Ã¯Â¿Â½Ã‚Â ÃƒÂ¦Ã‚Â¯Ã¢â‚¬ï¿½ÃƒÂ¤Ã‚Â¾Ã¢â‚¬Â¹ÃƒÂ¦Ã‹Å“Ã‚Â¯ÃƒÂ¥Ã‚Â¤Ã…Â¡ÃƒÂ¥Ã‚Â°Ã¢â‚¬ËœÃƒÂ¯Ã‚Â¼Ã…Â¸
ÃƒÂ¦Ã¯Â¿Â½Ã‚Â¢ÃƒÂ¥Ã¯Â¿Â½Ã‚Â¥ÃƒÂ¨Ã‚Â¯Ã¯Â¿Â½ÃƒÂ¨Ã‚Â¯Ã‚Â´ÃƒÂ¯Ã‚Â¼Ã…â€™ÃƒÂ¦Ã¢â‚¬Â°Ã¢â€šÂ¬ÃƒÂ¦Ã…â€œÃ¢â‚¬Â°ÃƒÂ§Ã¢â‚¬ï¿½Ã‚Â±ÃƒÂ¯Ã‚Â¼Ã‹â€ 080ÃƒÂ¯Ã‚Â¼Ã¢â‚¬Â°ÃƒÂ¥Ã‚Â¼Ã¢â€šÂ¬ÃƒÂ¥Ã‚Â¤Ã‚Â´ÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ¥Ã¯Â¿Â½Ã‚Â·ÃƒÂ§Ã‚Â Ã¯Â¿Â½ÃƒÂ¦Ã¢â‚¬Â¹Ã‚Â¨ÃƒÂ¥Ã¢â‚¬Â¡Ã‚ÂºÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ©Ã¢â€šÂ¬Ã…Â¡ÃƒÂ¨Ã‚Â¯Ã¯Â¿Â½ÃƒÂ¤Ã‚Â¸Ã‚Â­ÃƒÂ¯Ã‚Â¼Ã…â€™
ÃƒÂ¦Ã¢â‚¬Â°Ã¢â‚¬Å“ÃƒÂ¥Ã‚Â¾Ã¢â€šÂ¬ÃƒÂ§Ã¢â‚¬ï¿½Ã‚Â±ÃƒÂ¯Ã‚Â¼Ã‹â€ 080ÃƒÂ¯Ã‚Â¼Ã¢â‚¬Â°ÃƒÂ¥Ã‚Â¼Ã¢â€šÂ¬ÃƒÂ¥Ã‚Â¤Ã‚Â´ÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ¥Ã¯Â¿Â½Ã‚Â·ÃƒÂ§Ã‚Â Ã¯Â¿Â½ÃƒÂ¦Ã¢â‚¬Â°Ã¢â€šÂ¬ÃƒÂ¥Ã¯Â¿Â½Ã‚Â ÃƒÂ§Ã…Â¡Ã¢â‚¬Å¾ÃƒÂ¦Ã‚Â¯Ã¢â‚¬ï¿½ÃƒÂ¤Ã‚Â¾Ã¢â‚¬Â¹ÃƒÂ¦Ã‹Å“Ã‚Â¯ÃƒÂ¥Ã‚Â¤Ã…Â¡ÃƒÂ¥Ã‚Â°Ã¢â‚¬ËœÃƒÂ¯Ã‚Â¼Ã…Â¸

ÃƒÂ¨Ã‚Â¾Ã¢â‚¬Å“ÃƒÂ¥Ã¢â‚¬Â¡Ã‚ÂºÃƒÂ¤Ã‚Â¿Ã‚Â¡ÃƒÂ¦Ã¯Â¿Â½Ã‚Â¯:
"<percentage> percent of calls from fixed lines in Bangalore are calls
to other fixed lines in Bangalore."
ÃƒÂ¦Ã‚Â³Ã‚Â¨ÃƒÂ¦Ã¢â‚¬Å¾Ã¯Â¿Â½ÃƒÂ¯Ã‚Â¼Ã…Â¡ÃƒÂ§Ã¢â€žÂ¢Ã‚Â¾ÃƒÂ¥Ã‹â€ Ã¢â‚¬Â ÃƒÂ¦Ã‚Â¯Ã¢â‚¬ï¿½ÃƒÂ¥Ã‚ÂºÃ¢â‚¬ï¿½ÃƒÂ¥Ã…â€™Ã¢â‚¬Â¦ÃƒÂ¥Ã¯Â¿Â½Ã‚Â«2ÃƒÂ¤Ã‚Â½Ã¯Â¿Â½ÃƒÂ¥Ã‚Â°Ã¯Â¿Â½ÃƒÂ¦Ã¢â‚¬Â¢Ã‚Â°ÃƒÂ£Ã¢â€šÂ¬Ã¢â‚¬Å¡
"""
#Part I
def search_call_by_Bangalore(input):
    """List all phone numbers called by Bangalore users.

    input: list of calls
    call_by_Bangalore: list. list all area codes called by Bangalore users, include mobile phone and fixed lines
               if phone number is calling number or called number, duration will be added to dictionary value.
    """
    call_by_Bangalore = []
    for element in input:
        #print element
        #print element[0]
        if element[0].startswith("(080)"):
            if element[1].startswith("(0"):
                regx = re.findall(r'[^()]+',element[1])
                #split string with () to list, and use the first element 
                call_by_Bangalore.append(regx[0])
                #append fixed line area code to list
                #print "re.findall(r'[^()]+',element[1]) is {}".format(re.findall(r'[^()]+',element[1]))
                #print "re.findall(r'[^()]+',element[1]) type is {}".format(type(re.findall(r'[^()]+',element[1])))
                #print "phone number: {} call another phone number: {} with area code: {}".format(element[0], element[1], regx[0])
            
            #elif element[1].startswith('7' or '8' or '9') and element[1][5] == ' ':
            else:
                #print "element[1][0-4] is: ".format(element[1][0:5])
                call_by_Bangalore.append(element[1][0:4])
                #append mobile phone number first 5 numbers to list
                #print "phone number: {} call another phone number: {} with area code: {}".format(element[0], element[1], element[1][0:5])
    #print call_by_Bangalore
    call_by_Bangalore_set = set(call_by_Bangalore)
    #transfer list to set to remove same elements
    call_by_Bangalore_list = list(call_by_Bangalore_set)
    #transfer set to list, in order to sort. as set can't be sorted
    call_by_Bangalore_list.sort()
    #print call_by_Bangalore_set
    print ("The number called by people in Bangalore have codes:")
    print ('\n'.join(call_by_Bangalore_list))
    return call_by_Bangalore

#search_call_by_Bangalore(calls)

#Part II
def ratio_Bangalore_call_by_Bangalore(input):
    Bangalore_call_by_Bangalore = 0
    for element in input:
        #print element
        if element == "080":
           Bangalore_call_by_Bangalore += 1
           #print "element: {} was called {} times".format(element, Bangalore_call_by_Bangalore)
    ratio = float(Bangalore_call_by_Bangalore*100/len(input))
    print ("%.2f%% percent of calls from fixed lines in Bangalore are calls to other fixed lines in Bangalore." %(ratio))
    
ratio_Bangalore_call_by_Bangalore(search_call_by_Bangalore(calls))
            
   
            