Computer Science, asked by hardeepkaur0903, 12 hours ago

Kritika was asked to accept a list of even numbers but she did not put the relevant condition while accepting the list. Write a user-defined function oddtoeven(L) that accepts the List L as an argument and converts all the odd numbers into even by multiplying them by 2.​

Answers

Answered by samarthkrv
1

Answer:

def oddtoeven(L):

   for i in range(len(L)):

       if(L[i]%2 == 1):

           L[i] = L[i]*2

numbers = [9,8,4,5,2,7,1,3,0,2]

print("Original list-")

print(numbers)

oddtoeven(numbers)

print("List After converting every odd number in the list to even number-")

print(numbers)

Explanation:

Similar questions