Hi, I'm currently stuck with my homework. I need to know how to write this program in Python as below:
Write function repeatPhrase(phrase, n), which prints the given phrase n times, alternating between lowercase and uppercase. For example, repeat('The sky is blue', 5) would print:
the sky is blue
THE SKY IS BLUE
the sky is blue
THE SKY IS BLUE
the sky is blue
Please help me, thank you very much!
Answer for the above question :
code:
def repeatPhrase(phrase,n):
for i in range(n):
if(i%2==0):
print(phrase.lower())
else:
print(phrase.upper())
phrase=input("Enter the phrase: ")
n= int(input("Enther the repeations: "))
repeatPhrase(phrase,n)
OUTPUT:
PS:If you have any doubt mention in comment section. I will solve it as soon as possible
Get Answers For Free
Most questions answered within 1 hours.