List and Tuple creation

Generate a list and tuple with comma-separated numbers

1 Like

List_a=input().split()
Tup_a=tuple(List_a)

1 Like
values = input("Input some comma seprated numbers : ")
list = values.split(",")
tuple = tuple(list)
print('List : ',list)
print('Tuple : ',tuple)
1 Like

Create a list of tuples

data = [
(1, 2, 3),
(4, 5, 6),
(7, 8, 9)
]
for item in data:
print(item)

1 Like

n=[1, 2, 3, 4, 5]
m=(1, 2, 3, 4, 5)
print("list:- ",n)
print("tuple:- ",m)

1 Like

good. try it in the way to get input from user side

values = input("Input some comma seprated numbers : ")
list = (values.split)
tuple = tuple(list)
print(List : ,list)
print(Tuple : ,tuple)

1 Like

numbers = input("Input some comma-separated numbers : ")
list = (values.split)
tuple = tuple(list)
print(List : ,list)
print(Tuple : ,tuple)

1 Like

Num1= int(input(“enter the string”)
Num2= int(input(“enter the string”)
Num3= int(input(“enter the string”)
Num4= int(input(“enter the string”)
#tuple
for i in range(1,5)
i=tuple(i)
print(i “,”)
i=list(i)
print(i “,”)

1 Like

values = input("Input some comma seprated numbers : ")

list = values.strip(“,”)

tuple = tuple(list)

print('List : ',list)

print('Tuple : ',tuple)

1 Like

values = input("Input some comma seprated numbers : ")

list = values.split(“,”)

tuple = tuple(list)

print('List : ',list)

print('Tuple : ',tuple)

1 Like

li = []
for i in range(100, 401):
s = str(i)
if (int(s[0])%2==0) and (int(s[1])%2==0) and (int(s[2])%2==0):
li.append(s)
print(‘Generate a list with comma-separated numbers:’)
print( “,”.join(li))
tu = ()
tu = tuple(li)
print(‘Generate a tupple with comma-separated numbers:’)
print(“,”.join(tu))

1 Like

Solution:

a = input("Enter the sequence of numbers to create list: ")
b = input(“Enter the sequence of numbers to create tuple:”)

a1 = map(int, a.split(“,”))
b1= map(int, b.split(“,”))

a_list = list(a1)
b_tuple = tuple(b1)
print(a_list)
print(b_tuple)

Please find the solution I have posted in reply.

Please find the solution I have posted in reply.

Good. Please find the solution I have posted in reply.

Good try, but you have to convert the number into int format. Please find the solution I have posted in reply.

Good try! Please find the solution I have posted in reply.

Good try. Please the solution I have posted in reply.

Please the solution i have posted in reply.