fb pixel

Introduction to Python

  • Profound Academy

    • Status
      • 1
        Input and Output
      • 2
        Variables and Integer Arithmetic
      • 3
        Conditional Operators
      • 4
        Advanced Conditions - Nesting
      • 5
        Types and Variables
      • 6
      • 7
      • 8
        For Loops
      • 9
        While Loops
      • 10
        continue, break, while...else
      • 11
        String and List methods
      • 12
        Nested Loops
      • 13
        List Comprehension
      • 14
        Tuples and Sets
      • 15
      • 16
      • 17
        Functions 2
      • 18
        Lambda and higher-order functions
      • 19

  • in keyword

    Strings are pretty powerful and python has a diverse set of utilities to work with them. Some applications require checking if a string appears in another string. When searching a word on a website (Ctrl + F), we want to check if the word we typed appears in the text of the website.
    In python, checking if a string appears in another string can be done with the in keyword:
    word = 'access'
    text = 'The entire house was accessible through that underground tunnel'
    if word in text:
    	print('Yes, the word is in the text')
    	print('Not found...')
    It’s not mandatory for the first string to be only a word. It can be an arbitrary string. We can check for if 'some string with symb$ls' in text:.


    You are developing a chatbot. You would like to identify if a message was a greeting message. To do that you want to know if the message contains Hi, hi, Hello, or hello in it.
    Given a text, your task is to print Yes if the text is a greeting message and No otherwise.
    Hi, I would like to invite you to a conference
    My name is Bob
    To check your solution you need to sign in
    Sign in to continue