Skip to content

Commit 8fe76e6

Browse files
Conformed to Merge requirements
Ready for merge to parent repo
2 parents 1ee65c6 + becd0db commit 8fe76e6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
title: Truncate String
3-
description: Truncates a string to a specified length and adds a toggleable ellipsis.
3+
description: Truncates a string to a specified length and a toggleable truncation notation.
44
author: axorax
55
contributors: MinerMinerMods
66
tags: string,truncate
77
---
88

99
```py
1010
def truncate(s:str, length:int, suffix:bool = True) -> str :
11-
return (s[:length] + ("" if suffix else "")) if len(s) > length else s
11+
return (s[:length] + ("..." if suffix else "")) if len(s) > length else s
1212

1313
# Usage:
14-
truncate('This is a long string', 10) # Returns: 'This is a '
14+
truncate('This is a long string', 10) # Returns: 'This is a ...'
1515
truncate('This is a long string', 10, False) # Returns: 'This is a '
1616
```

0 commit comments

Comments
 (0)