How to show truncated (wrap shorten) text in Python

1 Answer

0 votes
import textwrap

s = """Python is a programming language that lets you work quickly 
       and integrate systems more effectively. The core of extensible programming 
       is defining functions. Python allows mandatory and optional arguments, 
       keyword arguments, and even arbitrary argument lists."""

dedent_text = textwrap.dedent(s)     
all = textwrap.fill(dedent_text, width=55)     

short_text = textwrap.shorten(all, 80)     
short_text_wrap = textwrap.fill(short_text, width=55)     
print(short_text_wrap)



'''
run

Python is a programming language that lets you work
quickly and integrate [...]

'''

 



answered Apr 26, 2019 by avibootz

Related questions

1 answer 152 views
152 views asked Aug 4, 2020 by avibootz
1 answer 249 views
249 views asked Aug 4, 2020 by avibootz
2 answers 233 views
1 answer 235 views
1 answer 93 views
1 answer 99 views
...