Skip to content
Advertisement

Tag: substring

Best practice when substring is missing from string

I’m extracting data from an API and one of the fields is a string from which i want to extract multiple substrings(7 ideally). To get those substring I’m using the index() method. There could be cases when one or more of these substrings(Reason ,Improvements_Done, Improvements_Planned etc) could be missing from the string. For example if “Improvements_Planned” is missing then i

How to replace and insert a new substring in python?

This is a working code and mabybe not very effcient code to replace a substring with another substring previously modified Input string : Output string: It has to replace substring like ‘part1’ ‘part2 an so on , with ‘PT’ and copy it between title and year substring Code: but when the list is like this I dont know how to

Advertisement