-1

I have a function which prints out the tally of pos/neg/neu scores of text.

So my output looks like:

# of sentences: 100
Pos Tally: 25
Neg Tally: 50
Neu Tally: 25

But instead of doing this for every text, I put the text into a list:

a = "How are you?"
b = "I am doing great."
c = "I am not doing well."

topics = [a,b,c]

For my function to print out 'a', 'b', 'c' before giving the tally, I assumed I should put the labels into a list.

labels = ['a','b','c']

So, I tried something along the lines of:

for i in topics:
    for label in labels:
        print(label, getSent(i))

This just prints out the entire label after each pos/neg/neu count.

I want my output to look like:

a
# of sentences: 1
Pos count: 1

b
# of sentences: 1

What can I do to make this work?

Thanks.

Shelina
  • 103
  • 6

1 Answers1

0

You should simply be able to use zip to iterate through your labels and topics side by side, here is an example (just using a random get_sent function):

def get_sent(topic):
  return '\nPositive: 1\n'

for i, j in zip(topics, labels):
  print(j, get_sent(i))

Output:

a 
Positive: 1

b 
Positive: 1

c 
Positive: 1
user3483203
  • 50,081
  • 9
  • 65
  • 94