0
Return a list containing every other element from an input list
Saludos a todos/as! (Greetings!). I need your assistance if it's possible, I'm finding a way to: "return a list containing EVERY OTHER ELEMENT from an input list, starting with the first element (that means included I think)", starting with a def function with one parameter, one variable that is an empty list and other variable that is equal to 0, with no modules, I can only use basic list functions, if anyone would be so kind to give me an example, thanks in advance!
4 Answers
+ 1
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥
Now is showing samples of input and output
0
https://code.sololearn.com/c8X7fCiGss7l/?ref=app
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥
This is the code that I'm trying to run, instead I'm getting empty lists and not the expected output.
0
Thanks 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 , sorry but, what about the if statement and the i += 1?, I'm asking you because usually on those lessons if we delete something, usually is not approved.
0
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚
Thanks, is showing IndexError in line 18,
if elements[i] in elements and i<x: