Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Python in Keyword

  • Last Updated : 30 Jan, 2020

In programming, a keyword is a “reserved word” by the language which conveys special meaning to the interpreter. It may be a command or a parameter. Keywords cannot be used as a variable name in the program snippet. Python language also reserves some of the keywords that convey special meaning. In Python, keywords are case sensitive.

“in” Keyword:

The in keyword has two purposes:

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

  • To check if a value is present in a list, tuple, range, string, etc.
  • To iterate through a sequence in a for loop.


# Using if statement
if ele in seq:

# Using for statement
for ele in seq:

Example 1:

# Python program to demonstrate
# in keyword
# Create a lits
animals = ["dog", "lion", "cat"]
# Check if lion in list or not
if "lion" in animals:



Example 2:

# Python program to demonstrate
# in keyword
# Create a string
s = "GeeksforGeeks"
# Iterating through the string
for i in s:
    # if f occurs in the string
    # break the loop
    if i == 'f':



My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!