Given a Tuple tup1= (10, 20, 30, 40, 50, 60, 70, 80, 90). What will be the output of print (tup1 [3:7:2])? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Given a Tuple tup1= (10, 20, 30, 40, 50, 60, 70, 80, 90). What will be the output of print (tup1 [3:7:2])?

13th Sep 2021, 4:26 PM
Abhinandh A
Abhinandh A - avatar
2 Answers
+ 3
Abhinandh A [3:7:2] means [start_index : end_index : step] and index start from 0 so at 3rd place value is 40 and step is 2 so next value will be 60. Since end_index is 7 but after 60 to 80 step is 2 but 80 will not be include in result because it's a end_index. So output is (40, 60)
13th Sep 2021, 4:56 PM
A͢J
A͢J - avatar
+ 2
Try it out in the playground and see for yourself
13th Sep 2021, 4:39 PM
Slick
Slick - avatar