Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 3 - Section 9 - Text Wrapping incorrect format #241

Open
BetoBob opened this issue Nov 4, 2020 · 0 comments
Open

Chapter 3 - Section 9 - Text Wrapping incorrect format #241

BetoBob opened this issue Nov 4, 2020 · 0 comments

Comments

@BetoBob
Copy link

BetoBob commented Nov 4, 2020

Current:

from textwrap import fill
>>> pieces = ["{} {}".format(word, len(word)) for word in saying]
>>> output = ' '.join(pieces)
>>> wrapped = fill(output)
>>> print(wrapped)
After (5), all (3), is (2), said (4), and (3), done (4), , (1), more
(4), is (2), said (4), than (4), done (4), . (1),

Output:

After 5 all 3 is 2 said 4 and 3 done 4 , 1 more 4 is 2 said 4 than 4
done 4 . 1

Fixed:

...
>>> pieces = ["{} ({}),".format(word, len(word)) for word in saying]
...

Output:

After (5), all (3), is (2), said (4), and (3), done (4), , (1), more
(4), is (2), said (4), than (4), done (4), . (1),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant