0

How can I reverse the string which includes numbers and letters, but I want to output the letters in reverse order. (Without using string functions)

string = 'Hellow 432'
length = len(string)
output = ""
while length>0:
   output += string[length-1]
   length = length-1
print (output)
Allan
  • 11
  • 2

1 Answers1

0
String details = "Hellow 432";
    string numeric = "";
    string nonnumeric = "";
    char[] mychar = details.ToCharArray();
    foreach (char ch in mychar)
    {
        if (char.IsDigit(ch))
        {

            numeric = numeric + ch.ToString();
        }
        else
        {
            nonnumeric =ch.ToString()+ nonnumeric;
        }
    }

 return nonnumeric + numeric;
}
Suman Kumar Dash
  • 681
  • 5
  • 19