SlideShare a Scribd company logo
Python program with functions that extracts specific characters from a text file. (e.g. .,#!?)
Solution
data=[] flag=False with open('/tmp/myFile.txt','r') as f: for line in f: if
line.startswith('&'): flag=True if flag: data.append(line) if
line.strip().endswith('#!?'): flag=False print ''.join(data)

More Related Content

More from FOREVERPRODUCTCHD

the largest drum ever constructed was played at the Rotal festival H.pdf
the largest drum ever constructed was played at the Rotal festival H.pdfthe largest drum ever constructed was played at the Rotal festival H.pdf
the largest drum ever constructed was played at the Rotal festival H.pdf
FOREVERPRODUCTCHD
 
Suppose that the material that you are recrystallizing fails to perc.pdf
Suppose that the material that you are recrystallizing fails to perc.pdfSuppose that the material that you are recrystallizing fails to perc.pdf
Suppose that the material that you are recrystallizing fails to perc.pdf
FOREVERPRODUCTCHD
 
Summarize the purpose of a WAN and define what makes up a WAN connec.pdf
Summarize the purpose of a WAN and define what makes up a WAN connec.pdfSummarize the purpose of a WAN and define what makes up a WAN connec.pdf
Summarize the purpose of a WAN and define what makes up a WAN connec.pdf
FOREVERPRODUCTCHD
 
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdf
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdfSOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdf
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdf
FOREVERPRODUCTCHD
 
Step 12 The task is complete when the quota can be verified. Take a.pdf
Step 12  The task is complete when the quota can be verified.  Take a.pdfStep 12  The task is complete when the quota can be verified.  Take a.pdf
Step 12 The task is complete when the quota can be verified. Take a.pdf
FOREVERPRODUCTCHD
 
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdf
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdfQUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdf
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdf
FOREVERPRODUCTCHD
 
Please answer the following question and all its parts. Please exp.pdf
Please answer the following question and all its parts. Please exp.pdfPlease answer the following question and all its parts. Please exp.pdf
Please answer the following question and all its parts. Please exp.pdf
FOREVERPRODUCTCHD
 
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdf
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdfPlease help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdf
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdf
FOREVERPRODUCTCHD
 
Know the different types of viruses which have a dsRNA genome A type.pdf
Know the different types of viruses which have a dsRNA genome  A type.pdfKnow the different types of viruses which have a dsRNA genome  A type.pdf
Know the different types of viruses which have a dsRNA genome A type.pdf
FOREVERPRODUCTCHD
 
In what ways do the experts foresee the use of both virtualization a.pdf
In what ways do the experts foresee the use of both virtualization a.pdfIn what ways do the experts foresee the use of both virtualization a.pdf
In what ways do the experts foresee the use of both virtualization a.pdf
FOREVERPRODUCTCHD
 
In the Meselson Stahl experiment, E. coli was grown for many generati.pdf
In the Meselson Stahl experiment, E. coli was grown for many generati.pdfIn the Meselson Stahl experiment, E. coli was grown for many generati.pdf
In the Meselson Stahl experiment, E. coli was grown for many generati.pdf
FOREVERPRODUCTCHD
 
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdfimplement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
FOREVERPRODUCTCHD
 
If a solution contains calcium ions (0.27 M) and barium ions (0.070 .pdf
If a solution contains calcium ions (0.27 M) and barium ions (0.070 .pdfIf a solution contains calcium ions (0.27 M) and barium ions (0.070 .pdf
If a solution contains calcium ions (0.27 M) and barium ions (0.070 .pdf
FOREVERPRODUCTCHD
 
I need to have the HTML separated from the Javascript. Also, I am vi.pdf
I need to have the HTML separated from the Javascript. Also, I am vi.pdfI need to have the HTML separated from the Javascript. Also, I am vi.pdf
I need to have the HTML separated from the Javascript. Also, I am vi.pdf
FOREVERPRODUCTCHD
 
I need a Thesis Statment for the following assignment.Write a pape.pdf
I need a Thesis Statment for the following assignment.Write a pape.pdfI need a Thesis Statment for the following assignment.Write a pape.pdf
I need a Thesis Statment for the following assignment.Write a pape.pdf
FOREVERPRODUCTCHD
 
Falafel Fineries common stock is selling for $40 a share. In lookin.pdf
Falafel Fineries common stock is selling for $40 a share. In lookin.pdfFalafel Fineries common stock is selling for $40 a share. In lookin.pdf
Falafel Fineries common stock is selling for $40 a share. In lookin.pdf
FOREVERPRODUCTCHD
 
Explain the differences between PL and PLE measurements; Explain why .pdf
Explain the differences between PL and PLE measurements; Explain why .pdfExplain the differences between PL and PLE measurements; Explain why .pdf
Explain the differences between PL and PLE measurements; Explain why .pdf
FOREVERPRODUCTCHD
 
Deflection by Integration and Superposition Derive equation of y usi.pdf
Deflection by Integration and Superposition  Derive equation of y usi.pdfDeflection by Integration and Superposition  Derive equation of y usi.pdf
Deflection by Integration and Superposition Derive equation of y usi.pdf
FOREVERPRODUCTCHD
 
Costs incurred in investigating the creation or acquisition of an ac.pdf
Costs incurred in investigating the creation or acquisition of an ac.pdfCosts incurred in investigating the creation or acquisition of an ac.pdf
Costs incurred in investigating the creation or acquisition of an ac.pdf
FOREVERPRODUCTCHD
 
concerning morbidity and mortality rates of diseases,Incidence rat.pdf
concerning morbidity and mortality rates of diseases,Incidence rat.pdfconcerning morbidity and mortality rates of diseases,Incidence rat.pdf
concerning morbidity and mortality rates of diseases,Incidence rat.pdf
FOREVERPRODUCTCHD
 

More from FOREVERPRODUCTCHD (20)

the largest drum ever constructed was played at the Rotal festival H.pdf
the largest drum ever constructed was played at the Rotal festival H.pdfthe largest drum ever constructed was played at the Rotal festival H.pdf
the largest drum ever constructed was played at the Rotal festival H.pdf
 
Suppose that the material that you are recrystallizing fails to perc.pdf
Suppose that the material that you are recrystallizing fails to perc.pdfSuppose that the material that you are recrystallizing fails to perc.pdf
Suppose that the material that you are recrystallizing fails to perc.pdf
 
Summarize the purpose of a WAN and define what makes up a WAN connec.pdf
Summarize the purpose of a WAN and define what makes up a WAN connec.pdfSummarize the purpose of a WAN and define what makes up a WAN connec.pdf
Summarize the purpose of a WAN and define what makes up a WAN connec.pdf
 
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdf
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdfSOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdf
SOS Please please please help on this problem!!!!!!!!!!!!!!!!!!!!!! .pdf
 
Step 12 The task is complete when the quota can be verified. Take a.pdf
Step 12  The task is complete when the quota can be verified.  Take a.pdfStep 12  The task is complete when the quota can be verified.  Take a.pdf
Step 12 The task is complete when the quota can be verified. Take a.pdf
 
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdf
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdfQUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdf
QUESTIONDiscuss how has Web 2.0 changed the behavior of Internet .pdf
 
Please answer the following question and all its parts. Please exp.pdf
Please answer the following question and all its parts. Please exp.pdfPlease answer the following question and all its parts. Please exp.pdf
Please answer the following question and all its parts. Please exp.pdf
 
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdf
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdfPlease help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdf
Please help, I cant figure out what I did wrong. Problem 11-2A (Pa.pdf
 
Know the different types of viruses which have a dsRNA genome A type.pdf
Know the different types of viruses which have a dsRNA genome  A type.pdfKnow the different types of viruses which have a dsRNA genome  A type.pdf
Know the different types of viruses which have a dsRNA genome A type.pdf
 
In what ways do the experts foresee the use of both virtualization a.pdf
In what ways do the experts foresee the use of both virtualization a.pdfIn what ways do the experts foresee the use of both virtualization a.pdf
In what ways do the experts foresee the use of both virtualization a.pdf
 
In the Meselson Stahl experiment, E. coli was grown for many generati.pdf
In the Meselson Stahl experiment, E. coli was grown for many generati.pdfIn the Meselson Stahl experiment, E. coli was grown for many generati.pdf
In the Meselson Stahl experiment, E. coli was grown for many generati.pdf
 
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdfimplement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
 
If a solution contains calcium ions (0.27 M) and barium ions (0.070 .pdf
If a solution contains calcium ions (0.27 M) and barium ions (0.070 .pdfIf a solution contains calcium ions (0.27 M) and barium ions (0.070 .pdf
If a solution contains calcium ions (0.27 M) and barium ions (0.070 .pdf
 
I need to have the HTML separated from the Javascript. Also, I am vi.pdf
I need to have the HTML separated from the Javascript. Also, I am vi.pdfI need to have the HTML separated from the Javascript. Also, I am vi.pdf
I need to have the HTML separated from the Javascript. Also, I am vi.pdf
 
I need a Thesis Statment for the following assignment.Write a pape.pdf
I need a Thesis Statment for the following assignment.Write a pape.pdfI need a Thesis Statment for the following assignment.Write a pape.pdf
I need a Thesis Statment for the following assignment.Write a pape.pdf
 
Falafel Fineries common stock is selling for $40 a share. In lookin.pdf
Falafel Fineries common stock is selling for $40 a share. In lookin.pdfFalafel Fineries common stock is selling for $40 a share. In lookin.pdf
Falafel Fineries common stock is selling for $40 a share. In lookin.pdf
 
Explain the differences between PL and PLE measurements; Explain why .pdf
Explain the differences between PL and PLE measurements; Explain why .pdfExplain the differences between PL and PLE measurements; Explain why .pdf
Explain the differences between PL and PLE measurements; Explain why .pdf
 
Deflection by Integration and Superposition Derive equation of y usi.pdf
Deflection by Integration and Superposition  Derive equation of y usi.pdfDeflection by Integration and Superposition  Derive equation of y usi.pdf
Deflection by Integration and Superposition Derive equation of y usi.pdf
 
Costs incurred in investigating the creation or acquisition of an ac.pdf
Costs incurred in investigating the creation or acquisition of an ac.pdfCosts incurred in investigating the creation or acquisition of an ac.pdf
Costs incurred in investigating the creation or acquisition of an ac.pdf
 
concerning morbidity and mortality rates of diseases,Incidence rat.pdf
concerning morbidity and mortality rates of diseases,Incidence rat.pdfconcerning morbidity and mortality rates of diseases,Incidence rat.pdf
concerning morbidity and mortality rates of diseases,Incidence rat.pdf
 

Recently uploaded

Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 

Recently uploaded (20)

Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 

Python program with functions that extracts specific characters from.pdf

  • 1. Python program with functions that extracts specific characters from a text file. (e.g. .,#!?) Solution data=[] flag=False with open('/tmp/myFile.txt','r') as f: for line in f: if line.startswith('&'): flag=True if flag: data.append(line) if line.strip().endswith('#!?'): flag=False print ''.join(data)