In a bank there are two types of transactions: credit and debit. All transactions are assigned an alphabetical ID. Credit transactions are assigned a vowel and debit transactions are assigned a consonant. To track transactions over a year, all the transaction IDs are combined to form a string of IDs for each customer. A customer wishes to know the number of times he made a debit transaction immediately after a credit transaction.
Write an algorithm to print the count of debit transactions that were made immediately afte a credit transaction for that particular customer.
Input
The first line of the input consists of a string userString, representing the string of transaction IDs.
Output
Print an integer representing the count of det transactions made immediately after a credit
1
Expert's answer
2021-09-01T07:54:28-0400
s = input('Transaction IDs: ').lower()
vowel = ('a', 'e', 'i', 'o', 'u', 'y')
count = 0
for index, i in enumerate(s[1:]):
if i not in vowel and s[index] in vowel:
count += 1
print(count)
Comments
Leave a comment