Skip to content

Instantly share code, notes, and snippets.

@ChaitanyaBaweja
Last active July 30, 2019 05:04
Show Gist options
  • Save ChaitanyaBaweja/aa800e7c8b00bdba5397386f37e614fd to your computer and use it in GitHub Desktop.
Save ChaitanyaBaweja/aa800e7c8b00bdba5397386f37e614fd to your computer and use it in GitHub Desktop.
old_list = [1, 2, 3, 4]
new_list = [i**3 if i%2 == 0 else i**2 for i in old_list]
print(new_list) # Output: [1, 8, 9, 64]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment