0
Add elements in tuple
The first line contains (a total number of elements initially) and in next n line containing space separated tuple elements. In last line have index value and element followed by space
4 Answers
+ 2
l = []
for _ in range(int(input())):
l.append(input())
# out of loop
index, value = input().split()
l.insert(int(index), value)
t = tuple(l)
print(t)
0
Sample inputs
5
abda
cgsl
123
held
Hold
3 three
## it needs to insert three at index value 3
Sample output#it should be in tuple
('abda','cgsl',123,'three','Held','Hold')
0
n=input()
list=[]
for i in range(0,n):
list.append(input())
last_line=input()
spl=last_line.split()
pos=int(spl[0])
ele=spl[1]
list.insert(pos,ele)
print(tuple(list))
0
Understood thanks