list - Python - How do you assign a variable to a table displayed on seperate lines -


sorry horrible title. im trying here

import pyperclip y = [] x in range(1,158):     y.append("- " + str(x))   pyperclip.copy(y) 

what table, when copied clipboard pasted left right want elements of list pasted downward

so instead of

1 2 3 4 5 

i'd get

1 2 3 4 5 

is there anyway this?

you need newline characters, '\n', in string. try this

import pyperclip y = [] x in range(1,158):     y.append("- " + str(x) + '\n')  pyperclip.copy(y) 

a more pythonic way be

import pyperclip y = '\n'.join('- ' + str(x) x in range(1, 158)) pyperclip.copy(y) 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -