Wednesday, October 28, 2015

Convert a list to tuple

#Question:
#Write a program to generate and print another tuple2 ==0 
#whose values are even numbers in the given tuple (1,2,3,4,5,6,7,8,9,10).

#a=tuple()
tp=(1,2,3,4,5,6,7,8,9,10)
li=list()
for i in tp:
    if i%2==0:
        li.append(i)

tp2=tuple(li)
print tp2

No comments:

Post a Comment