Finding element from tuple

Question

How will you find the third through sixth elements from the tuple below (using a single line of code) ?

my_tuple=(10, 20, 30, 40, 50, 60, 80, 100)

in progress 0
YashikaKhurana 55 years 3 Answers 754 views Master 0

Answers ( 3 )

  1. You just need a single line of code to do this->
    print(my_tuple[3:7])

  2. # Printing 3rd to 6th element
    print(my_tuple[2:6]);

Leave an answer

Browse
Browse