Computer Science, asked by Mallappa2740, 1 year ago

In python write a program to find the alternate element of a tuple

Answers

Answered by fiercespartan
2

Let's say we have a tuple will numbers

numbers = (1,2,3,4,5)

Now, we want to print every alternate number in the tuple. That is 1,3 and 5.

To do that, first we will take the length of the tuple and set it as our range and then put our skip as 2 and not 1.

for x in range(0,len(numbers),2):

   print(numbers[x])

Similar questions