Write a program to find all occurrences of “USA” in a given string ignoring the case.
Given:
str1 = "Welcome to USA. usa awesome, isn't it?"
Expected Outcome:
The USA count is: 2
Hint:
Use the string function count()
count()
Solution:
str1 = "Welcome to USA. usa awesome, isn't it?" sub_string = "USA" # convert string to lowercase temp_str = str1.lower() # use count function count = temp_str.count(sub_string.lower()) print("The USA count is:", count)
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Hint:
Use the string function
count()
Solution:
need an explanation for this answer? contact us directly to get an explanation for this answer