Question: #THIS IS THE CODE: tv = [ 'r24_getrenderingmode', 'r24_panel', 'r24_pcpar', 'Literal question:', 'Which party would

#THIS IS THE CODE:    tv = [        'r24_getrenderingmode',        'r24_panel',        'r24_pcpar',        'Literal question:',        'Which party would you vote for today?',        'r24_pcpar_13_other',        'Literal question:',        'Other:',        'Post question:',        'KIWI:',        'r24_pcpak',        'r24_pcpak_16_other',        'r24_pcpaf',        'Literal question:',        'Which party would you vote for?',    ]    rex = []    for i in tv:        if i[0] == "r":            rex.append(i)            for i in range(len(tv)-1):        if tv[i+1] in rex:            print(tv[i])        if tv[i+1] not in rex:            print("•", tv[i])

The output is:

 

r24_getrenderingmode
r24_panel
• r24_pcpar
• Literal question:
Which party would you vote for today?
• r24_pcpar_13_other
• Literal question:
• Other:
• Post question:
KIWI:
r24_pcpak
r24_pcpak_16_other
• r24_pcpaf
• Literal question:

 

How can I modify it so that
the last elem not in rex is also included?
DESIRED OUTPUT:


r24_getrenderingmode
r24_panel
• r24_pcpar
• Literal question:
• Which party would you vote for today?
• r24_pcpar_13_other
• Literal question:
• Other:
• Post question:
• KIWI:
r24_pcpak
r24_pcpak_16_other
• r24_pcpaf
• Literal question:
• Which party would you vote for?

 

Also it is NOT nessesary, but If you could add all the elements in the desired output in a new empty list, and then

make all the elements in the new list, if i[0] = ''•", be added into one element in the list. It should look like this:

r24_getrenderingmode
r24_panel
• r24_pcpar, Literal question, Which party would you vote for today?
• r24_pcpar_13_other, Literal question:, Other:, Post question:, KIWI:
r24_pcpak
r24_pcpak_16_other
• r24_pcpaf, Literal question:, Which party would you vote for?

 

Again, you do NOT have to, only if it's not too much trouble for you and you feel like it.  If you can just get the code to print out the desired output, I will still give you great reviews.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!