-1

How to Convert a string like '123' to int 1,2 and 3 so that I can perform 1+2+3. I am new to python. Can you please help me? I am not able to split the list. I don't think splitting the string will be of any use as there are no delimiters. Can you help me to understand how can this string elements be separated and treated as intergers?

Selva
  • 17
  • 1

1 Answers1

2
x = "123"
s = 0
for a in x:
   s = int(a) + s
Schniddi
  • 57
  • 1
  • 1
  • 7
amritanshu
  • 777
  • 13
  • 25