Assume two banks want to establish a secure communication ch
Assume two banks want to establish a secure communication channel so that they can share amount of money at each bank. They agree that number of \'s\' character represents amount of dollars and number of \'c\' character represents number of cents. For example, the sentence is \"This is a program that is written in C code.\" contains three \'S\'s and two \'C\'s, which means the sender has three dollars and two cents. Write a program in Python that satisfy the above goal. That is, your Python code requests a user to enter an arbitrary sentence and presents number of \'S\'s, number of \'C\'s, and the total amount of money in dollar and cents. Enter an arbitrary sentence: This is a program that is written in C code The sentence contains: 3 \'S\'s The sentence contains: 2 \'C\'s The amount of in dollar: 3 Dollars The amount of money in cents: 2 cents
Solution
input_string = input(\"Enter an arbitrary sentence: \")
s_count = 0
c_count = 0
for i in range(len(input_string)):
if input_string[i].lower() == \'s\':
s_count += 1
elif input_string[i].lower() == \'c\':
c_count += 1
else:
pass
print(\"The Sentence Contains: \" + str(s_count) + \' Ss\')
print(\"The Sentence Contains: \" + str(c_count) + \' Cs\')
print(\"The amount of money in dollar: \" + str(s_count) + \' Dollars\')
print(\"The amount of money in cents: \" + str(c_count) + \' Cents\')
