+ 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

19th Jan 2020, 10:07 AM
Lalit kumar
Lalit kumar - avatar
8 Respostas
+ 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
19th Jan 2020, 3:33 PM
Ipang
+ 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?
19th Jan 2020, 10:21 AM
Ipang
+ 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?
19th Jan 2020, 11:23 AM
Ipang
+ 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.
19th Jan 2020, 2:23 PM
Ipang
+ 1
T=eval(input(Enter list:)) length=len(T) for a in range (length) : if a=a+2: print(a)
19th Jan 2020, 3:13 PM
Lalit kumar
Lalit kumar - avatar
+ 1
I got it thanks
19th Jan 2020, 3:43 PM
Lalit kumar
Lalit kumar - avatar
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
19th Jan 2020, 10:50 AM
Lalit kumar
Lalit kumar - avatar
0
I tried but not getting output by for loop Just getting by slicing tuple
19th Jan 2020, 2:21 PM
Lalit kumar
Lalit kumar - avatar