Skip to main content
added 91 characters in body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214

Python 3, 26 bytes

print('abc'[::-(1/2>0)|1])

Try it online!

Python 2, 26 bytes

print('abc'[::-(1/2>0)|1])

Try it online!

25-byte version with exit instead, which outputs to STDERR instead.

This is basically the same as print('abc'[::[1,-1][1/2>0]]), just that it's golfed.

Python 3, 26 bytes

print('abc'[::-(1/2>0)|1])

Try it online!

Python 2, 26 bytes

print('abc'[::-(1/2>0)|1])

Try it online!

25-byte version with exit instead, which outputs to STDERR instead.

Python 3, 26 bytes

print('abc'[::-(1/2>0)|1])

Try it online!

Python 2, 26 bytes

print('abc'[::-(1/2>0)|1])

Try it online!

25-byte version with exit instead, which outputs to STDERR instead.

This is basically the same as print('abc'[::[1,-1][1/2>0]]), just that it's golfed.

deleted 8 characters in body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214

Python 2Python 3, 2726 bytes

print('abc'[::-(1/2==02>0)|1])

Try it online!Try it online!

Python 3Python 2, 2726 bytes

print('abc'[::-(1/2==02>0)|1])

Try it online!Try it online!

25-byte version with exit instead, which outputs to STDERR instead.

Python 2, 27 bytes

print('abc'[::-(1/2==0)|1])

Try it online!

Python 3, 27 bytes

print('abc'[::-(1/2==0)|1])

Try it online!

Python 3, 26 bytes

print('abc'[::-(1/2>0)|1])

Try it online!

Python 2, 26 bytes

print('abc'[::-(1/2>0)|1])

Try it online!

25-byte version with exit instead, which outputs to STDERR instead.

Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214

Python 2, 27 bytes

print('abc'[::-(1/2==0)|1])

Try it online!

Python 3, 27 bytes

print('abc'[::-(1/2==0)|1])

Try it online!