Skip to content

Instantly share code, notes, and snippets.

@Pierian-Data
Created March 1, 2018 17:23
Show Gist options
  • Select an option

  • Save Pierian-Data/5767f49f825dbc9f9bf1357b2152b010 to your computer and use it in GitHub Desktop.

Select an option

Save Pierian-Data/5767f49f825dbc9f9bf1357b2152b010 to your computer and use it in GitHub Desktop.
def myfunc(x):
out = []
for i in range(len(x)):
if i%2==0:
out.append(x[i].lower())
else:
out.append(x[i].upper())
return ''.join(out)
@Arthiar
Copy link

Arthiar commented Oct 9, 2025

def myfunc(x):
out = []
for i in range(len(x)):
if i%2==0:
out.append(x[i].lower())
else:
out.append(x[i].upper())
return ''.join(out)
print(myfunc("Hello this is Arthi, and I am a student, and I am learning how to work consistently on functions by doing exercises"))

def myfunc(x):
out = []
for word in x.split():
if len(word) % 2 == 0:
out.append(word.lower())
else:
out.append(word.upper())
return ' '.join(out)
print(myfunc("Hello this is Arthi, and I am a student, and I am learning how to work consistently on functions by doing exercises"))

@RahulAmbiger11
Copy link

#10.
def myfunc(x):
out = []

for i in range(len(x)):
    if i%2==0:
        out.append(x[i].lower())
    else:
        out.append(x[i].upper())
return ''.join(out)

res1 = myfunc("Sudeep")
print(res1)

res2 = myfunc("Yash")
print(res2)

@Bjorn-Suerink
Copy link

Bjorn-Suerink commented Nov 6, 2025

def myfunc(s):
num=0
word=''
for letter in s:
if num%2 == 0:
word += letter.lower()
else:
word+= letter.upper()
num+=1
return word
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment