On Unix system type files can be identified with the ls -l command which displays the type of the file in the first alphabetic letter of the file system permissions field. You can find more information about file type on Unix system on the [wikipedia page](https://en.wikipedia.org/wiki/Unix_file_types).

- '-' A regular file ==> `file`.
- 'd' A directory ==> `directory`.
- 'l' A symbolic link ==> `symlink`.
- 'c' A character special file. It refers to a device that handles data as a stream of bytes (e.g: a terminal/modem) ==> `character_file`.
- 'b' A block special file. It refers to a device that handles data in blocks (e.g: such as a hard drive or CD-ROM drive) ==> `block_file`.
- 'p' a named pipe ==> `pipe`.
- 's' a socket ==> `socket`.
- 'D' a door ==> `door`.

In this kata you should complete a function that return the `filetype` as a string regarding the `file_attribute` given by the `ls -l` command. 

For example if the function receive `-rwxr-xr-x` it should return `file`.

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def linux_type(file_attribute):
	

Solutions:
dict = {'-': 'file', 'd': 'directory', 'l': 'symlink', 'c': 'character_file', 'b': 'block_file', 'p': 'pipe', 's': 'socket', 'D': 'door'}

def linux_type(file_attribute):
	return dict[file_attribute[0]]


def linux_type(s):
	return {x: y for (x, y) in zip('-dlcbpsD', 'file directory symlink character_file block_file pipe socket door'.split(' '))}[s[0]]


d = dict(__import__('re').findall("'(.)'.*\\s([a-z_]+)\\.", "\n        '-' A regular file ==> file.\n        'd' A directory ==> directory.\n        'l' A symbolic link ==> symlink.\n        'c' A character special file. It refers to a device that handles data as a stream of bytes (e.g: a terminal/modem) ==> character_file.\n        'b' A block special file. It refers to a device that handles data in blocks (e.g: such as a hard drive or CD-ROM drive) ==> block_file.\n        'p' a named pipe ==> pipe.\n        's' a socket ==> socket.\n        'D' a door ==> door.\n    "))
linux_type = lambda s: d[s[0]]


def linux_type(f):
	return {'-': 'file', 'd': 'directory', 'l': 'symlink', 'c': 'character_file', 'b': 'block_file', 'p': 'pipe', 's': 'socket', 'D': 'door'}.get(f[0])


import re

def linux_type(file_attribute):
	types = {'-': 'file', 'd': 'directory', 'l': 'symlink', 'c': 'character_file', 'b': 'block_file', 'p': 'pipe', 's': 'socket', 'D': 'door'}
	return types[file_attribute[0]]


linux_type = lambda f: {'-': 'file', 'd': 'directory', 'l': 'symlink', 'c': 'character_file', 'b': 'block_file', 'p': 'pipe', 's': 'socket', 'D': 'door'}[f[0]]


def linux_type(file_attribute):
	types = {'-': 'file', 'd': 'directory', 'l': 'symlink', 'c': 'character_file', 'b': 'block_file', 'p': 'pipe', 's': 'socket', 'D': 'door'}
	if not file_attribute:
		return None
	ty = file_attribute[0]
	if ty in types:
		return types[ty]
	else:
		return None


def linux_type(file_attribute):
	f_att = file_attribute[0]
	if f_att == '-':
		return 'file'
	elif f_att == 'd':
		return 'directory'
	elif f_att == 'l':
		return 'symlink'
	elif f_att == 'c':
		return 'character_file'
	elif f_att == 'b':
		return 'block_file'
	elif f_att == 'p':
		return 'pipe'
	elif f_att == 's':
		return 'socket'
	elif f_att == 'D':
		return 'door'
	return None


def linux_type(file_attribute):
	Unix_system_type = [['-', 'file'], ['d', 'directory'], ['l', 'symlink'], ['c', 'character_file'], ['b', 'block_file'], ['p', 'pipe'], ['s', 'socket'], ['D', 'door']]
	i = 0
	while i < len(Unix_system_type):
		if file_attribute[0] == Unix_system_type[i][0]:
			return Unix_system_type[i][1]
		i += 1