python - More elegant way to do this? -


pretty simple piece of code, seems way verbose though. there nicer way in 1 line? out of curiosity. it's in python 3.5.

if predictedclassification >= 0.5:    predictedclassification = 1 else    predictedclassification = 0 

you can write as:

predictedclassification = 1 if predictedclassification >= 0.5 else 0 

Comments