Answered step by step
Verified Expert Solution
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started