Saturday, 26 November 2016

convert tuple to list

#convert a list of numbers into tuple

#defining list
l=[]

#entering numbers into list
ch='y'
while(ch!='n'):
    n=int(input("enter no:"))
    l.append(n)
    ch=input('do you want to continue:')

#to display list
print('list of entered numbers:',l)

#to display tuple
print('tuple of list:',tuple(l))

OUTPUT:

   

No comments:

Post a Comment