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 254 views
254 views asked Aug 4, 2020 by avibootz
1 answer 346 views
346 views asked Aug 4, 2020 by avibootz
2 answers 360 views
1 answer 358 views
1 answer 104 views
1 answer 184 views
...