They Might be Giants has a song called Es Eat Anything At th

They Might be Giants has a song called \"E\'s Eat Anything\". At the conclusion of the song we find that the letter Z likes to eat letter E\'s. Count how many times the letter Z is followed by the letter E in a string.

We are using Python

Solution

#declaring a string
string = \"ZE fm leZ sE ze\"

#making the string lowercase
string_lower = string.lower()

#initilialising the counter varaible
n = 0

#for loop to iterate through the string
for i in range(len(string_lower)-1):
    #checking if character z is followed by e
    if string_lower[i]==\"z\" and string_lower[i+1]==\"e\":
        n+=1 #incrementing the counter

#printing out the number of times z is followed by e
print \"Number of times Z is followed by E: \", n

They Might be Giants has a song called \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site