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

Count letters after a specific word

I have this response from a server: HTTP-Version: WEB 981.20\r\n\r\nlogintype=none&since=today

I know you can count letters by using the function len() but this function will count all letters of the response.

How can I count the letters after this phrase: HTTP-Version: WEB 981.20\r\n\r\n?

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

The result should be 26.

>Solution :

Try out this python code:

response = "HTTP-Version: WEB 981.20\r\n\r\nlogintype=none&since=today"
substring = response.split("HTTP-Version: WEB 981.20\r\n\r\n")[1]
print(substring)

This code just grabs whatever is after the string you provided and puts it into a substring

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