[Introduction to Udemy Python 3 + Application] 36. How to use In and Not

** * This article is from Udemy "[Introduction to Python3 taught by active Silicon Valley engineers + application + American Silicon Valley style code style](https://www.udemy.com/course/python-beginner/" Introduction to Python3 taught by active Silicon Valley engineers + application + American Silicon Valley style code style ")" It is a class notebook for myself after taking the course of. It is open to the public with permission from the instructor Jun Sakai. ** **

■ Usage of In and Not

◆ Basic usage

in_and_not


y = [1, 2, 3]
x = 1

if x in y:
    print('in')

if 100 not in y:
    print('not in')

result


in
not in
◆ If not should not be used

not


a = 1
b = 2

#Than doing this
if not a == b:
    print('Not equal')

#Should do this
if a != b:
    print('Not equal')

result


Not equal
Not equal
◆ not for boolean type

boolean_not


is_ok = True

if not is_ok:
    print('hello')

result


It may be a little unpleasant if you don't get used to it, Familiarize yourself with the boolean type, which is often described with not.

Recommended Posts

[Introduction to Udemy Python 3 + Application] 36. How to use In and Not
[Introduction to Udemy Python3 + Application] 23. How to use tuples
[Introduction to Udemy Python3 + Application] 27. How to use the dictionary
[Introduction to Udemy Python3 + Application] 30. How to use the set
[Introduction to Python] How to use class in Python?
How to use is and == in Python
[Introduction to Udemy Python3 + Application] 64. Namespace and Scope
[Introduction to Python] How to use the Boolean operator (and ・ or ・ not)
[Introduction to Udemy Python3 + Application] 68. Import statement and AS
[Introduction to Udemy Python 3 + Application] 58. Lambda
[Introduction to Udemy Python 3 + Application] 31. Comments
[Introduction to Udemy Python 3 + Application] 57. Decorator
How to use SQLite in Python
[Introduction to Udemy Python3 + Application] 59. Generator
How to use Mysql in python
How to use ChemSpider in Python
How to use PubChem in Python
[Introduction to Udemy Python 3 + Application] Summary
[Introduction to Udemy Python3 + Application] 42. for statement, break statement, and continue statement
[Introduction to Udemy Python3 + Application] 39. while statement, continue statement and break statement
Comparison of how to use higher-order functions in Python 2 and 3
[Introduction to Udemy Python3 + Application] 50. Positional arguments, keyword arguments, and default arguments
[Introduction to Udemy Python3 + Application] 18. List methods
[Introduction to Udemy Python3 + Application] 28. Collective type
[Introduction to Udemy Python3 + Application] 25. Dictionary-type method
[Introduction to Udemy Python3 + Application] 33. if statement
How to install and use pandas_datareader [Python]
[Introduction to Udemy Python3 + Application] 55. In-function functions
[Introduction to Udemy Python3 + Application] 48. Function definition
[Introduction to Udemy Python 3 + Application] 10. Numerical values
[Introduction to Udemy Python3 + Application] 21. Tuple type
[Introduction to Udemy Python3 + Application] 45. enumerate function
[Introduction to Udemy Python3 + Application] 41. Input function
[Introduction to Udemy Python3 + Application] 17. List operation
[Introduction to Udemy Python3 + Application] 65. Exception handling
[Introduction to Udemy Python3 + Application] 11. Character strings
[Introduction to Udemy Python3 + Application] 44. range function
[Introduction to Udemy Python3 + Application] 46. Zip function
[Introduction to Udemy Python3 + Application] 24. Dictionary type
python: How to use locals () and globals ()
How to use __slots__ in Python class
How to use Python zip and enumerate
[Introduction to Udemy Python3 + Application] 8. Variable declaration
How to use regular expressions in Python
[Introduction to Udemy Python3 + Application] 29. Set method
[Introduction to Udemy Python3 + Application] 16. List type
[Introduction to Udemy Python3 + Application] 61. Dictionary comprehension
[Introduction to Udemy Python 3 + Application] 22. Tuple unpacking
[Introduction to Udemy Python3 + Application] 49. Function citation and return value declaration
How to use functions in separate files Perl and Python versions
[Introduction to Python] How to use the in operator in a for statement?
[Introduction to Udemy Python3 + Application] 69. Import of absolute path and relative path
[Introduction to Udemy Python3 + Application] 12. Indexing and slicing of character strings
How to use the C library in Python
[Introduction to Udemy Python 3 + Application] 26. Copy of dictionary
How to generate permutations in Python and C ++
[Introduction to Udemy Python3 + Application] 60. List comprehension notation
How to use Python Image Library in python3 series
[Introduction to Udemy Python 3 + Application] 38. When judging None
Summary of how to use MNIST in Python
[Introduction to Udemy Python3 + Application] 40.while else statement