quick and hopefully easy question.
Let’s say I have a variable that is equal to a numerical width value
i.e.: size_x = 50
I want to print the list, wrapping to a width of 50 elements. How do I do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
guess 1: print lines containing only size_x elements of the original list
guess 2: a new list of which the elements are strings of only size_x characters
printing newlist of ‘guess 2’ all at once to the screen is quicker than first guess:
print('\n'.join(newlist))(also note that prior to python 3,
xrange()can be used instead ofrange(), which generates i-values ‘on the go’ instead of creating a whole list of indices first. Python 3 does this standard withrange())example