human
Sum of all substrings of a string representing a number | Set 2 ( Constant Extra Space ) | Returns sum of all substring of num.
Initialize result.
Here traversing the array in reverse order . Initializing loop from last element . mf is multiplying factor ..
Each time sum is added to its previous sum . Multiplying the three factors as explained above . int ( s [ i ] ) is done to convert char to int ..
Making new multiplying factor as explained above ..
Driver code to test above methods"
How can the above be solved in Python?
 ... What is a code to sum of all substrings of a string representing a number and the other steps required?
assistant
#Here is code to sum of all substrings of a string representing a number and the other steps required.
 def sumOfSubstrings ( num ) :
	sum = 0
		mf = 1
		for i in range ( len ( num ) - 1 , - 1 , - 1 ) :
			sum = sum + ( int ( num [ i ] ) ) * ( i + 1 ) * mf
			mf = mf * 10 + 1
		return sum
if __name__ == ' _ _ main _ _ ' :
	num = "6759"
	print ( sumOfSubstrings ( num ) )