Python: Display formatted text as output
Python String: Exercise-26 with Solution
Write a Python program to display formatted text (width=50) as output.
import textwrap sample_text = ''' Python is a widely used high-level, general-purpose, interpreted, dynamic programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than possible in languages such as C++ or Java. ''' print() print(textwrap.fill(sample_text, width=50)) print()
Python is a widely used high-level, general- purpose, interpreted, dynamic programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than possible in languages such as C++ or Java.
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a Python program to create a Caesar encryption.
Next: Write a Python program to remove existing indentation from all of the lines in a given text.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
Python: Tips of the Day
Returns a list of elements that exist in both lists, after applying the provided function to each list element of both.
def tips_intersection_by(a, b, fn): _b = set(map(fn, b)) return [item for item in a if fn(item) in _b] from math import floor print(tips_intersection_by([2.1, 1.2], [2.3, 3.4],floor))
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises