+ 2
How to write a program that:
Inputs a tuple and creates a new tuple that contains everything third element of the original tuple by using for loop
8 Answers
+ 2
Lalit kumar
I made it like this, test it out, and feel free to ask in case something is unclear.
https://code.sololearn.com/cMA31jlN3mSq/?ref=app
+ 2
"Contains everything third element of the original tuple"
I am not understanding this, you want everything or just the third element? or every element on index a multiple of 3?
+ 1
That's not what I had in mind for third element actually. The third element in that tuple is 3. You are asking for elements whose value are multiple of 3, or elements that are at third, sixth, ninth index (multiple of 3).
Can I see your code?
+ 1
Doesn't matter, I just wanna see how far you go. Maybe I can help you a bit if I can see the code.
+ 1
T=eval(input(Enter list:))
length=len(T)
for a in range (length) :
if a=a+2:
print(a)
+ 1
I got it thanks
0
Just third element
like if tuple is (1,2,3,4,5,6,7,8,9)
It should print output as 3,6,9
0
I tried but not getting output by for loop
Just getting by slicing tuple