Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON 3 If I have a list of list, how do I concatenate certain elements together? example: contents = [ ['queue', 'contents'], ['submit', '1', '%turkey',

PYTHON 3

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

example:

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']]

How can I concatenate all the elements between the string starting with "%" and the string that ends with "%" (strings with "%" included)?

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

Step: 3

blur-text-image

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

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions

Question

When should you avoid using exhaust brake select all that apply

Answered: 1 week ago

Question

What is the environment we are trying to create?

Answered: 1 week ago

Question

How can we visually describe our goals?

Answered: 1 week ago