Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

ternary operator in python

smaller, larger = 7, 50
  
# Copy value of a in min if a < b else copy b
min = smaller if smaller < larger else larger
  
print(min)

#equivalent to the (condition)?(if true) :(if false) in javascript
Source by book.pythontips.com #
 
PREVIOUS NEXT
Tagged: #ternary #operator #python
ADD COMMENT
Topic
Name
5+5 =