In python, we can check if a list contains certain element. For this “in” keyword is helpful. Example selected_candidates=[“rahul”,”ajay”,”vijay”] #check if raju is present in the list if “raju” in selected_candidates: print(“Raju has been selected for the job”) else: print(“Raju has been disqualified for the job”) Output: Raju has been disqualified for the job.
Tag: python list
Python List
List in Python programming is a type of variable which holds one or more than one elements. List Declaration We can use any name that has no space or any special character to declare a variable of type list. Example fruitnames=[“Orange”,”Banana”,”Grape”,”Pine Apple”,”Jackfruit”] roll_numbers=[101,102,103,104,105] While declaring list, square brackets are important. The starting square bracket, and […]
Python Data Types
In one of the previous tutorial, I have discussed about variable declaration. Variable are declared to store values in it. We can store different types of values in a variable. Lets learn in this tutorial, what are the different types of data we can store in a variable. String String data type are the general […]