-
-
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) |
def my fun(x):
out = [ ]
for in range(Len(x)):
if I%2==0:
out.append(x([I].upper())
else:
out.append(x[I].lower())
return ".join(out)
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"))
#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)

Skyline
def myfunc(mystring):
mylist = []
for index in range(len(mystring)):
if index % 2 == 0:
mylist.append(mystring[index].upper())
else:
mylist.append(mystring[index].lower())
return ''.join(mylist)
Output:
myfunc('abcde')
'AbCdE'