1. Write a python script to combine first 2 and last 2 elements from the tuple.
eg :-
t= ("book", 2020, "CS", 500, "GRAM", "Thomas", "7 edition")
output must be :-
("book", 2020, "CS", "7 edition")
Answers
Answered by
21
Answer:
If you want the first and last 2 elements the output should be,
('book', 2020, '7 edition', 'Thomas')
And the program goes like:
If you want the wanted output as you mentioned,
The program goes like:
BrainlyIAS:
Nice :-)
Answered by
18
t = ("book", 2020, "CS", 500, "GRAM", "Thomas", "7 edition")
# combine first 2 and last 2 items
print(t[0:2] + t[-2:])
# output as shown in your question which is not what the question asks
print(t[0:3] + t[-1:])
Similar questions