Computer Science, asked by akkunirmal, 9 months ago

WAP to print the alternate elements of a tuple T.​

Answers

Answered by harshkhandelwal51
2

Answer:

# Python code to demonstrate  

# to construct alternate element list  

# using list comprehension  

 

# initializing list  

test_list = [1, 4, 6, 7, 9, 3, 5]  

 

# printing original list  

print ("The original list : " + str(test_list))  

 

# using list comprehension  

# to construct alternate element list  

res = [test_list[i] for i in range(len(test_list)) if i % 2 != 0]  

 

# printing result  

print ("The alternate element list is : " + str(res))

Similar questions