Skip to main content
2 of 7
added 59 characters in body
Justin
  • 21.3k
  • 9
  • 67
  • 114

#Python - 31 28

Uses a generator function to save 1 char, so it is necessary to print the value with some function that uses a generator/iterator, like for i in a(b):print(i)

def a(b):yield((b<0)*-2+1)*b

Old one:

def a(b):yield b if b>0 else-b
Justin
  • 21.3k
  • 9
  • 67
  • 114