I have the following Code in Python:
def show_sequence(n):
if n > 0:
return "+".join((str(i) for i in range(n+1))) + " = %d" %(sum(range(n+1)))
elif n == 0:
return "0=0"
else:
return str(n) + "<0"
Question: Is there a syntax correct way of putting all lines into one return statement if there are 3 if-statements? I know it works with one if- & else-statement but im a fan of one-liner and already asked this myself several times.