Conversion In String


Suppose this is a string :slight_smile: : “123A3212” [var str string = “123A3212”]

but i want to add consecutive digits elements of string (i.e 1+2 and 2+3… ) ignoring the alphabets and print the sum of digit of each pair.

Help Me With This

1 Like

As this really sounds like a homework assignment, could you please tell us first what you have tried so far and what you are struggling with now?

1 Like

waiting I am putting a question here

1 Like

You have not answered my question, please show us what you have tried so far. We won’t give you a pre made solution…


Here The Code

1 Like


Don’t have time to code now, but I would try to do something like this. Just skip the first character of the string and then do your calculation. It would give something like :


And now it seems that if you consider the columns and the nature of the character (digit or letter), you can just add easily term by term the elements of the columns of the two strings.
Try it.

1 Like

thanks i understand that

1 Like

As I am learning Go too, this kind of questions make to figure out how to solve… :slight_smile:
Here my version(

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.