Python the fourth time----if statement

Source: Internet
Author: User

1. The core of each if statement is an expression with a value of true or false, which is called a conditional test

2. An equal sign is a statement, two equals is a question, check if the case is not considered equal

Car = ' BMW '

Car = = ' Audi '

FALSE

3. Most conditional expressions written check that two values are equal, but sometimes it is more efficient to check whether two values are unequal

4. Fruits = [' apple ', ' orange ', ' banana ']

' Apple ' in fruits

True

5. In the IF statement, the indentation is the same as in the For loop

6. The IF-ELIF-ELSE structure is powerful, but only suitable for situations where only one condition is satisfied, in short, if you want to execute only one block of code, use the IF-ELIF-ELSE structure, and if you want to run multiple blocks of code, use a series of independent if statements

7. current_users=[' Houbashu ', ' admin ', ' root ', ' Gaoyang '

new_users=[' Houbashu ', ' Mengqi ']

For user in New_users:

If user in Current_users:

Print ("repeat")

Else

Print ("new")

Python the fourth time----if statement

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.