Truncate the given string (first argument) if it is longer than the given maximum length (second argument). Return the truncated string with a `"..."` ending.

Note that inserting the three dots to the end will add to the string length.

However, if the given maximum string length num is less than or equal to 3, then the addition of the three dots does not add to the string length in determining the truncated string.


## Examples
```
('codewars', 9)  ==>  'codewars'
('codewars', 7)  ==>  'code...'
('codewars', 2)  ==>  'co...'
```

[Taken from FCC](https://www.freecodecamp.com/challenges/truncate-a-string)

Difficulty: EASY
Starter code: def truncate_string(str,n):
	

Solutions:
def truncate_string(s, n):
	return s if len(s) <= n else s[:n if n <= 3 else n - 3] + '...'


def truncate_string(str, n):
	if len(str) <= n:
		return str
	if n <= 3:
		return str[0:n] + '...'
	else:
		return str[:n - 3] + '...'


def truncate_string(str, n):
	if n >= len(str):
		return str
	return [str[:n] + '.' * 3, str[:n - 3] + '.' * 3][n > 3]


def truncate_string(s, max_len):
	if len(s) <= max_len:
		return s
	return '{}...'.format(s[:max_len - (3 if max_len > 3 else 0)])


truncate_string = lambda s, n: s[:n - 3 * (3 < n < len(s))] + '...' * (n < len(s))


truncate_string = lambda str, n: str if n >= len(str) else str[:n - 3 if n > 3 else n] + '...'


def truncate_string(s, n):
	if n >= len(s):
		return s
	elif n <= 3:
		return s[:n] + '...'
	return s[:n - 3] + '...'