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')


More Questions


4 . 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.
5 . Write a Python program that accepts a filename from the user and prints the extension of the file.
6 . Write a Python program to display the first and last colors from the following list.
7 . Write a Python program that accepts an integer (n) and computes the value of n+nn+nnn.
8 . Write a Python program that prints the calendar for a given month and year.
9 . Write a Python program to calculate the number of days between two dates.
10 . Write a Python program to get the volume of a sphere with radius six.
11 . Write a Python program to calculate the sum of three given numbers. If the values are equal, return three times their sum.
12 . Write a Python program to count the number 4 in a given list.
13 . Write a Python program to get n (non-negative integer) copies of the first 2 characters of a given string. Return n copies of the whole string if the length is less than 2.
14 . Write a Python program to test whether a passed letter is a vowel or not.



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

Programs