t3=('sun','mon','tue','wed','thru','fri')
if 'sun' in t3 :
for i in range (0,3) :
print(t2[i])
else:
for i in range (3,6) :
print(t2[i]) find output
Answers
Answer:
actual question is:
t3=('sun','mon','tue','wed','thru','fri')
if 'sun' in t3 :
for i in range (0,3) :
print(t3[i])
else:
for i in range (3,6) :
print(t3[i])
answer:
sun
mon
tue
Explanation:
we have taken a tuple datatype elements named as t3.
Then condition is if "sun" is exist in t3 then it goes to the if-block.
Here there is a for loop like---> it takes a variable called i and range is (0,3) this means it has to iterate 3 times(that is i =0, i = 1, i = 2).
then it prints the tuple elements with the help of index.
coming to else part first if-condition has to fail then only compiler will come to the else-block without executing if-block.
Again there is a for loop like---> it takes a variable called i and range is (3,6) this means it has to iterate 3 times(that is i =3, i = 4, i = 5).
then it prints the tuple elements with the help of index.