def truncate(s, n): '''Return s truncated to n characters.''' return s if len(s) <= n else s[:n-3] + '...'