Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

if else not providing desired output

My conditional function is not working. Where is the issue?

From the below text, if "DFF Manufacturing Company" available, then it will print the name.

DFF  DFF  Manufacturing  Company  QWE  LIMITED 
DFF  Strasse  16  O  Strasse  103 
96032,  Germany  23467,  Germany 

Python code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

if "DFF  Manufacturing  Company" in text.split('\n'):
    print("DFF Manufacturing Company")

Output:
No result is showing

>Solution :

if you want to split lines and need to check every line, you have to check by loop.

for line in text.split('\n'):
   if "DFF  Manufacturing  Company" in line:
      print("DFF Manufacturing Company")
      #break #if you want to check once

if you want to check in full paragraph , use below code

if "DFF  Manufacturing  Company" in text:
    print("DFF Manufacturing Company")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading