-7

Simple question from a simple guy..

How i convert x = ['30+20'] or x = ['1-500'] list string to int ?

Im trying to get out the operation of that list[string].

x = [50] or x = [-499]

Sabata
  • 1
  • 2
    Welcome to Stack Overflow. **Why** do you want to do this? Where does the data come from? And what is so important about the list? If you can do this for an individual string, it should be easy to repeat for an entire list, right? – Karl Knechtel Sep 21 '22 at 18:11

1 Answers1

1
x = ['30+20'] 
print(sum([int(i) for i in x[0].split('+')]))

this gives just int without list
if you need it inside of list just wrap it into list()

Dmitriy Neledva
  • 867
  • 4
  • 10