Write a Python program that accepts a sequence of comma-separated numbers from the user and generates a list and a tuple of those numbers.

Program


def myfun():
    
    values = input("Input some comma-separated numbers: ")
    list1 = values.split(",")
    tuple1 = tuple(list1)
    
    # Print the list
    print('List : ', list1)

    # Print the tuple
    print('Tuple : ', tuple1)
      
if __name__=="__main__":      
    myfun()

Output:

Input some comma-separated numbers: 12,34,36,78,35,79
List : ['12', '34', '36', '78', '35', '79']
Tuple : ('12', '34', '36', '78', '35', '79')

For latest job updates join Telegram Channel: https://t.me/sateeshm

Programs