id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

rnewton31@gatech.edu ds-attendance > weird_transformation
prev  |  next  |  chance

Given a list of data points, transform the data according to the following rules:

If the index (starting at zero) of the data point is even, add the index to the data point. If the index (starting at zero) of the data point is odd, subtract the index from the data point.

Return the transformed data.


weird_transformation([1, 2, 3, 4]) → [1, 1, 5, 1]
weird_transformation([0, 5, 6]) → [0, 4, 8]
weird_transformation([0, 0, 0, 0, 0, 0]) → [0, -1, 2, -3, 4, -5]

...Save, Compile, Run (ctrl-enter)

def weird_transformation(data):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 150

Copyright Nick Parlante 2017 - privacy