0% found this document useful (0 votes)
20 views5 pages

Programming Challenges and Solutions

Uploaded by

henakhadeeja99
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views5 pages

Programming Challenges and Solutions

Uploaded by

henakhadeeja99
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Programming questions

Ans )

def EOReplace(L):
for i in range(len(L)):
if L[i] % 2 == 0: # even
L[i] = L[i] + 1
else: # odd
L[i] = L[i] - 1
print(L)

L = [10, 20, 30, 40, 35, 55]


EOReplace(L)
def Puzzle(W, N):
res = "" # empty string to store result
for i in range(len(W)):
if (i+1) % N == 0: # check if position is Nth
res = res + "_"
else:
res = res + W[i]
return res

# Example
print(Puzzle("TELEVISION", 3)) # TE_EV_SI_N

You might also like