Python: Removing parentheses and string in between them?
-
Question: This function remove_parentheses(s) takes one string parameter s, and returns that same string in which all text in between parentheses has been removed, including the ...show more
-
Answer:
In Python, it is important to show indentation (which Y!A removes) so either use "--- " for each indentation level, or use #end comments to delimit blocks, or use a code-posting site and post the link here. def remove_parentheses(s): --- result = "" --- flag = True --- for c in s: --- --- if c == "(": flag = False --- --- if flag: result += c --- --- if c == ")": flag = True --- return result
LPYYHYF7R4VWT62VDWFJO4SSFM at Yahoo! Answers Visit the source
Related Q & A:
- How to Convert Json date string to more readable date format?Best solution by SharePoint
- How to see if one string contains another string?Best solution by Stack Overflow
- Is Yahoo removing adult profiles?Best solution by in.answers.yahoo.com
- What Mods/Repairs can I do to my d16 vtech engine without removing it to make it like new again?Best solution by Yahoo! Answers
- Removing your own Y! ID from other people's list?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.