0

Variable (python)

if have a variable var={hei {123}} I want to remove the outer brackets without the inner ones being affected. is there a way to do so in 1 line of code in python?

15th Sep 2018, 8:08 AM
Sahil Danayak
Sahil Danayak - avatar
3 Respuestas
+ 5
I don't really know what you're trying to do, what kind of variable that is and why it needs to be done in one line of code, but in case it's a string, you can try something like: var = '{hei{123}}' print(var.replace('{', '', 1).replace('}}', '}'))
15th Sep 2018, 9:27 AM
Anna
Anna - avatar
+ 1
What is that variable supposed to be? It's not even python syntax It is probably possible if you clarify what kind of data that is supposed to be
15th Sep 2018, 9:15 AM
Markus Kaleton
Markus Kaleton - avatar
+ 1
thanks
15th Sep 2018, 12:04 PM
Sahil Danayak
Sahil Danayak - avatar