You are on page 1of 3

In list

--------
# creating an empty list
lst = []
 
# number of elements as input
n = int(input("Enter number of elements : "))
 
# iterating till the range
for i in range(0, n):
    ele = int(input())
 
    lst.append(ele) # adding the element
     
print(lst)

In tuple

--------

t = input()

a = tuple(int(x) for x in t.split())

#view this tuple

print(a)

In tuple through list

----------------------

# creating an empty list

lst = []
# number of elemetns as input

n = int(input("Enter number of elements : "))

# iterating till the range

for i in range(0, n):

ele = (input())

lst.append(ele) # adding the element

tupl=tuple(lst) #converting list into tuple

print(tupl) #print tuple

In tuple

-----------

t=tuple()

n = int(input())

i=1

while i<=n:

a=int(input()

t=t+(a,)

i=i+1

print(t)
In dictionary

------------------

fruits = {}

for i in range(2):

key = input("Enter key for fruits:")

value = input("Enter value for fruits:")

fruits[key] = value

You might also like