Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Automate the Boring Stuff - Project Wiki bullets- Can't get it to run

So I'm working on the project above on Wiki bullets. I have the same code as the book however I'm not sure how to use the pyperclip to get it running on my batch. file:

@py C:\Users\david\MyPythonScripts\AddingBullets.py %*

@pause

I can't input a string in the cmd line and I don't know where to input a string in the code to see it work. I've tried putting it in pyperclip.copy() and pyperclip.paste(), as well as the final 'text' variable (lines). But it just doesn't show anything. Any guesses?

#! python3
# AddingBullets.py - Adds Wikipedia bullet points to the start
# of each line of text on the clipboard.

import pyperclip


text = pyperclip.paste()

# Separate lines and add stars.
lines = text.split('\n')
for i in range(len(lines)):    # loop through all indexes for "lines" list
    lines[i] = '* ' + lines[i] # add star to each string in "lines" list
text = '\n'.join(lines)

pyperclip.copy(text)