Константин обнови решението на 20.03.2015 15:00 (преди над 9 години)
+def extract_type(archive, key):
+ return ''.join([str(item[0]) * item[1] for item in archive
+ if type(item[0]) is key])
+
+
+def reversed_dict(dictionary):
+ return {value: key for key, value in dictionary.items()}
+
+
+def flatten_dict(dictionary, prev_key=''):
+ new_dict = {}
+ for key, value in dictionary.items():
+ new_key = prev_key + key
+ if isinstance(value, dict):
+ new_dict.update(flatten_dict(value, new_key + '.'))
+ else:
+ new_dict[new_key] = value
+ return new_dict
+
+
+def reps(iterable):
+ return tuple(item for item in iterable if iterable.count(item) > 1)