Not in Keyword in Python Code Example

Last Updated On Thursday 2nd Jun 2022
  • Not Operator, which takes whatever expression you have and inverts it.

Working with a boolean

	followMe = True

if not followMe:
    print("Oh You Miss the Awesome things")
	
	# You can see nothing happens; it will not print anything.
	

let if followMe is False

	followMe = False

if not followMe:
    print("Oh, You Miss the Awesome things")
	
	# Oh, You Miss the Awesome things
	
	followMe = True

if not followMe:
  print("Oh You Miss the Awesome things :(")
else:
  print("You Done it !! :)")
	
	# You Done it !! :)
	

not in python

	names = ["Adam", "Alice", "Sam", "Ben", "Tom", "Harry"]

if "Jofra" not in names:
    print("Oh, this name is not in lists")
else:
    print("Yes")
	
	# Oh, this name is not in lists