Feb-26-2023, 04:58 PM
Hi.
I'm trying to learn Python by reading the book called "Automate the boring stuff", and have written my first project which I have copied from the book.
It's supposed to copy text from a clipboard, and add (*) in front of each line, but when I run it nothing happens. I have copied a random text on a website with Ctrl+C. Not sure if this is the right way to do it
Can someone tell me what I'm doing wrong?
My code:
I'm trying to learn Python by reading the book called "Automate the boring stuff", and have written my first project which I have copied from the book.
It's supposed to copy text from a clipboard, and add (*) in front of each line, but when I run it nothing happens. I have copied a random text on a website with Ctrl+C. Not sure if this is the right way to do it

Can someone tell me what I'm doing wrong?
My code:
#! python 3 # bulletPointAdder.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 in the "lines" list lines[i] = '* ' + lines[i] # add star to each string in "lines" list text = '\n'.join(lines) pyperclip.copy(text)
Error:Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
= RESTART: C:\Users\Lenovo\Documents\Python\Automate_the_boring_stuff\Projects\bulletPointAdder.py
>>>