In this article, you will learn how to find the longest substring in ascending order and compute the average with python. To understand this program, you should have knowledge of the following Python Programming topics:

Problem Definition

Assume s is a string. Write a program that prints a substring of numbers, the longest substring of s in which the numbers occur in ascending order, and compute the average of the numbers found. For example, if s = ‘56aaww1984sktr235270aYmn145ss785fsq31D0‘, then your program should print. Keep in mind – you need to accept the string from the user.

In the case of ties, print the first substring. For example, if s = ’14erq72lkm79′, then your program should print


  1. Take input from the user and store them in variables
  2. Remove all non-numerical character
  3. Print the final number
  4. Find and Print the longest sub-string number from the number
  5. Calculate and Print the average of the longest substring number
  6. End


The article was published on October 7, 2020 @ 2:15 PM

Leave a Comment