Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. class MimePair:
  2.  
  3.     def __init__(self, ext, mt):
  4.         self.ext = ext
  5.         self.mt = mt
  6.  
  7. # Auto-generated code below aims at helping you parse
  8. # the standard input according to the problem statement.
  9.  
  10. n = int(raw_input())  # Number of elements which make up the association table.
  11. q = int(raw_input())  # Number Q of file names to be analyzed.
  12.  
  13. mimeList = []
  14.  
  15. for i in xrange(n):
  16.     # ext: file extension
  17.     # mt: MIME type.
  18.     ext, mt = raw_input().split()
  19.     mimeList.append(MimePair(ext.lower(), mt))
  20.        
  21. for i in xrange(q):
  22.     fname = raw_input().split('.')  # One file name per line.
  23.     searchFlag = 0
  24.     match = [x for x in mimeList if x.ext == fname[-1].lower()]
  25.     if len(match) > 0 and len(fname) > 1:
  26.         print match[0].mt
  27.     else:
  28.         print 'UNKNOWN'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement