string & textwrap

Lab Python Intermediate 20 points

Read a width and a paragraph. Print the paragraph wrapped to that width with textwrap.fill, then print how many of its characters are in string.punctuation.

Input

Line 1: width. Line 2: text.

Output

The wrapped text, then the count.

Example

Input

20
Python is easy to learn, powerful, and fun! Isn't it?

Output

Python is easy to
learn, powerful, and
fun! Isn't it?
5
Sample input available Sample output available
Editor
Python

Hints

textwrap.fill breaks text into lines no longer than the width.

string.punctuation is a string of punctuation characters.

Solution explanation

Small standard modules like textwrap and string save lots of fiddly code.

Show solution
import string
import textwrap

width = int(input())
text = input()
print(textwrap.fill(text, width))
print(sum(ch in string.punctuation for ch in text))
Output
Answer
HOME LEARN COMMUNITY DASHBOARD