Home > Backend Development > Python Tutorial > Does the ternary operator exist in Python?

Does the ternary operator exist in Python?

silencement
Release: 2019-05-25 15:41:44
Original
3729 people have browsed it

Does the ternary operator exist in Python?

There are no ternary expressions in other languages ​​in python, but there are similar implementation methods.

For the following requirements

Does the ternary operator exist in Python?

1. The ternary expression in other languages ​​​​(such as java) is as follows

Does the ternary operator exist in Python?

2. There are only similar alternatives in python, which are slightly different from other languages, as follows

Does the ternary operator exist in Python?

You can also use a simple formula, as follows,

Does the ternary operator exist in Python?

The above is the detailed content of Does the ternary operator exist in Python?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template