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