I would like to have the text printed out as how it shown on the exercise whereby the Lists of List has a *
on each line and each are in a new line. I am still new to python and the Automate the Boring Stuff with Python book is kind of confusing sometimes.
I started by typing the text into the Python editor and having Pyperclip to copy it unto the clipboard. The problem is Pyperclip only accepts a single string, in which form the text is copied to the clipboard.
#! python3
#bulletPointerAdder.py - Adds Wikipedia bullet points to the start
#of each line of text on the clipboard.
#! python3
#bulletPointerAdder.py - Adds Wikipedia bullet points to the start #of each line of text on the clipboard.
In the Python shell:
import pyperclip
>>> text = 'Lists of monkeys Lists of donkeys Lists of pankeys'
>>> pyperclip.copy(text)
>>>
RESTART: C:\Users\User\AppData\Local\Programs\Python\Python37-
32\bulletpointadder.py >>> text '* Lists of monkeys Lists of donkeys Lists of pankeys' >>>
import os
import pyperclip
text = pyperclip.paste()
#Separate lines and add starts.
lines = text.split(os.linesep)
for i in range(len(lines)): # loop through all indexes in the "lines"
list
lines[i] = '* ' + lines[i] # add star to each sting in "lines" list
text = os.linesep.join(lines)
pyperclip.copy(text)
I actually want the text to be printed out like the sample below, but the problem is I am getting it print out as a single string.
- Lists of animals
- Lists of aquarium life
- Lists of biologists by author abbreviation
- Lists of cultivars