Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
example:- 1st string= sgb2453
2nd string= jhh2bh2
sum = 18

What I have tried:

Python
a=list(input("enter a string "))
b=list(input("enter another string "))
c=a+b
print(c)
d=0
for i in range (1,len(c)+1):



i stuck here
Posted
Updated 23-Sep-18 22:20pm
Comments
Maciej Los 24-Sep-18 2:15am    
Do you mean:
string1 = 2+4+5+3=14
string2 = 2+2=4
14+4=18?

1 solution

Try
Python
a=list(input("enter a string "))
b=list(input("enter another string "))
c=a+b
print(c)
d=0
for i in range (0,len(c)):
  ch = c[i]
  if ch >='0' and ch <='9':
    d = d + ord(ch) - ord('0')
print(d)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900