Skip to content

Instantly share code, notes, and snippets.

@sjparkinson sjparkinson/mime.py
Created Oct 17, 2016

Embed
What would you like to do?
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
mime_types = {}
file_names = []
count_mime_types = int(input()) # Number of elements which make up the association table.
count_file_names = int(input()) # Number of file names to be analyzed.
for i in range(count_mime_types):
extension, value = input().split()
mime_types[extension.lower()] = value
for i in range(count_file_names):
file_name = input()
# There may not be an extension...
if "." in file_name:
# Second value is the extension.
file_extension = file_name.rsplit(".", 1)[1].lower()
# Lookup with a default value.
print(mime_types.get(file_extension, "UNKNOWN"))
else:
print("UNKNOWN")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.