[Tutor] (no subject)

singh000taran at gmail.com
Sat Feb 27 02:09:55 EST 2021


Sir,

For the question -

Define a function called myfunc that takes in a string, and returns a
matching string where every even letter is uppercase, and every odd letter
is lowercase. Assume that the incoming string only contains letters, and
don't worry about numbers, spaces or punctuation. The output string
can start with either an uppercase or lowercase letter, so long as letters
alternate throughout the string.


I tried -


def mufunc(**kwargs):

    finaloutput = '' "

    i = 0

    while i < len(kwargs):

        if i%2 == 0:

            finaloutput = finaloutput + kwargs[i].upper()

        else:

            finaloutput = finaloutput + kwargs[i].lower()

        i = i + 1

    return finaloutput

myfunc('Anthropomorphism')


It's not working. Please guide me.


Thanking you

Yours sincerely

Tarandeep Singh


More information about the Tutor mailing list