0

Edit: I realize the question is confusing now, so I will try to clarify. For the code I am using I don't know what the lists that are being outputted are. All I know is that (using the example) when I print(j), it turns out like the output I have put below. I hope that clears up any confusion.

I am creating a program that will use OCR to read documents then output text. The problem is for the program to work I need the text output to be a list. How can I convert it to a list?

This is not the specific code but an example.

l = ['3']
m = ['2']
n = ['1']
for j in (l,m,n):
        print(j)

In this example I can't change j or anything before j.

The output:

['3']
['2']
['1']

The real code has b = list but I can't change any of the code before b.

I want it to look like this:

['3', '2', '1']
2
  • Hey You can look at my answer for other possible ways for concatenating as well. Commented Jun 12, 2019 at 18:28
  • There are many options and some of them are present in answers. Was just curious why there is only one element in all of the list? I would opt of variables rather. Commented Jun 12, 2019 at 18:36

2 Answers 2

1

When you did (l,m,n) that made a tuple object. You can append lists using the + operator.

l = ['3']
m = ['2']
n = ['1']
j = l + m + n
print(j)

output:

['3', '2', '1']
Sign up to request clarification or add additional context in comments.

Comments

0

list concatenation works with the addition sign:

new_list = l + m + n

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.