Skip to content

Commit 6ee6b02

Browse files
committed
replace ternary syntax
1 parent eb77e87 commit 6ee6b02

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Python/chapter01/1.6 - String Compression/miguel_1.6_sol.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def str_compression(s: str) -> str:
3737
compressed.append(prev_char)
3838
compressed.append(str(count)[0])
3939

40-
return ''.join(compressed) if len(compressed) < len(s) else s
40+
if len(compressed) >= len(s):
41+
return s
42+
return ''.join(compressed)
4143

4244

4345
class TestStringCompressionFunction(unittest.TestCase):

0 commit comments

Comments
 (0)