Q:

Write a Python program to count number of non-empty substrings of a given string

0

Write a Python program to count number of non-empty substrings of a given string

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def number_of_substrings(str): 
	str_len = len(str); 
	return int(str_len * (str_len + 1) / 2); 

str1 = input("Input a string: ")
print("Number of substrings:") 
print(number_of_substrings(str1))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now