how to obtain the content of brackets

Solutions on MaxInterview for how to obtain the content of brackets by the best coders in the world

showing results for - "how to obtain the content of brackets"
Giovanni
25 Mar 2019
1"""
2This will try to split the argument into 2, using the square brackets, then
3will split the index one, so, the variable foo just is the content of
4any group of characters. like ()[]{}
5"""
6try:
7  foo = arg.split("[")[1].split("]")[0]
8except:
9# The argument doesn't contain a class.
10    pass