So I made a Example List looking like this:
dataList = ["tv", "•", "tv", "tv", "•", "tv", "•", "tv", "tv", "•"]
I want to print out the Items that are enclosed by •.
In this example,
tv, tv
tv
tv, tv
I came up with the following code:
num = 0
num2 = 0
index = 0
boolean = True
for index, elem in enumerate(dataList2):
boolean = True
num = index + 1,
num = int(num[0])
if elem == "•":
counter = 0
if boolean:
boolean = False
for elem2 in dataList2[num:]:
counter = counter + 1,
counter = int(counter[0])
if elem2 == "•":
print("\n")
num2 = counter + num,
num2 = int(num2[0])
for el in dataList2[num:num2]:
print(el, end=" ")
I get this output:
tv tv •
tv tv • tv •
tv tv • tv • tv tv •
tv •
tv • tv tv •
tv tv •
As you can see I get the unwanted behaviour that
tv tv • tv •
tv tv • tv • tv tv •
tv • tv tv •
are included in the output. I tried to fix the behaviour with a boolean but that didnt work out. What did I do wrong?