Skip to content
Advertisement

Tag: string

How to sort the contents of a list?

I have the following list: I need to make a list of book titles ordered by year, with the underscore character and the year removed. For example, the first book title should be “SecretOfChimneys”. Call your list booktitles. Is there a way to use the fact that titles are already sorted by year in books and just select the tiles

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

Python fix french accents parsed as =C3=A9

In python i’m stuck with a couple of strings from french language with accents that I can’t convert back to normal, e.g.: Most documentation I read specify to read the files with some encodings=’utf-8′ or so, but here I’m stuck with actual strings. Is there a way to decode the strings or should I build a maximega .replace() function ?

Advertisement