I have the following code:
a = True
x = [2, 7, 8]
print(x)
if a:
x.append(10)
print(x)
# one line ???
y = [2, 7, 8 if a: 10]
print(y)
I'm trying to use if statement in one line, but I get invalid syntax. Any ideas?
I have the following code:
a = True
x = [2, 7, 8]
print(x)
if a:
x.append(10)
print(x)
# one line ???
y = [2, 7, 8 if a: 10]
print(y)
I'm trying to use if statement in one line, but I get invalid syntax. Any ideas?