Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON 3 PYTHON 3 If I have a list of list, how do I concatenate certain elements together? This lists of lists here has to

PYTHON 3

PYTHON 3

If I have a list of list, how do I concatenate certain elements together?

This lists of lists here has to change. What I am trying to do is change all the elements between the string starting with "%" and the string that ends with "%" (strings with "%" included)

for example:

['submit', '%turkey', 'wrap', 'large', 'coffee%', '8.25']

has to change into

['submit', '%turkey wrap large coffee%', '8.25']

contents = [ ['queue', 'contents'], ['submit', '1', '%turkey', 'wrap', 'large', 'coffee%', '8.25'], ['next', 'order'], ['submit', '2', '%mushroom', 'soup', 'chocolate', 'dip', 'donut%', '7.59'], ['next', 'order'], ['submit', '3', '%ham', 'and', 'swiss', 'chocolate', 'milk%', '8.29'], ['queue', 'contents'], ['sleep', '4'], ['complete'], ['submit', '4', '%grilled', 'cheese', 'turkey', 'wrap%', '15.42'], ['sleep', '2'], ['complete'], ['queue', 'contents'], ['modify', '3', '%large', 'coffee%', '2.95'], ['sleep', '2'], ['complete'], ['queue', 'contents'], ['cancel', '1'], ['next', 'order'], ['submit', '5', '%potato', 'wedges', 'large', 'coffee%', '8.65'], ['queue', 'contents'], ['submit', '6', '%steak', 'wrap', 'medium', 'coffee%', '9.39'], ['sleep', '3'], ['queue', 'contents'], ['submit', '7', '%chicken', 'noodle', 'soup%', '3.25'], ['queue', 'contents'], ['modify', '1', '%donut%', '.99'], ['cancel', '6'], ['submit', '8', '%turkey', 'wrap', 'large', 'coffee%', '8.25'], ['cancel', '4'], ['queue', 'contents'], ['cancel', '8'], ['queue', 'contents']]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

List some problems associated with risk tolerance questionnaires.

Answered: 1 week ago