Category: Python
Python : How to Iterate over a list ?
In this article we will discuss different ways to iterate over a list. Iterate over the list using for-in loop Its easies solution to iterate over the list i.e. Advertisements ”’ Iterate over the list using for loop ”’ for word in wordList: print(word) Output hi hello this that is of Iterate over the list …
Python : How to Insert an element at specific index in List ?
In this article we will discuss how to insert an element in list at specific position. Inserting an element in list at specific index using list.insert() In python list provides a member function insert() i.e. Advertisements list.insert(position, element) It accepts a position and an element and inserts the element at given position in the list. …
Python : How to Insert an element at specific index in List ?Read More
Python : 6 Different ways to create Dictionaries
In this article, we will discuss different ways to create dictionary objects in python. What is a dictionary? dictionary is an associative container that contains the items in key/value pairs. For example, we if want to track the words and their frequency count in an article like, Advertisements “Hello” occurs 7 times “hi” occurs 10 times …
Remove key from Dictionary in Python
In this article we will discuss 6 different ways to delete a key from a dictionary in python. Subscribe Table Of Contents Remove a key from a dictionary using dict.pop() Delete a Key from dictionary if exist using pop() Remove a key from a dictionary using items() & for loop Remove a key from a …
Python: Iterate / Loop over Dictionary (All key-value pairs)
In this article we will discuss different ways to iterate over all key-value pairs of a dictionary. Table of Contents: Iterate over a dictionary using for loop over keys Iterate over key-value pairs of dictionary using dict.items() Iterate over a dictionary using list comprehension Iterate over specific key-value pairs of dictionary Suppose we have a …
Python: Iterate / Loop over Dictionary (All key-value pairs)Read More
Python : How to create a list of all the Values in a dictionary ?
In this article we will discuss how to create a list of all the values in dictionary. Suppose we have a dictionary of string and integers i.e. Advertisements # Dictionary of string and int wordFreqDic = { “Hello”: 56, “at” : 23 , “test” : 43, “this” : 2, “here” : 23, “city” : 2, …
Python : How to create a list of all the Values in a dictionary ?Read More
How to create a Directory in python ?
In this article we will discuss different APIs in python to create directories. Creating a Directory in Python Python’s OS module provides a function to create a directory i.e. Advertisements os.mkdir(path) It creates a directory with given path i.e. os.mkdir(‘tempDir’) It creates the directory ‘tempDir’ in current directory. Frequently Asked: Find the smallest file in …
python : How to create a list of all the keys in the Dictionary ?
In this article we will discuss how to create a list of all keys in a dictionary. Suppose we have a dictionary of string and integers i.e. Advertisements # Dictionary of string and int wordFreqDic = { “Hello”: 56, “at” : 23 , “test” : 43, “this” : 78, “here” : 18, “city” : 2, …
python : How to create a list of all the keys in the Dictionary ?Read More
Python : How to Remove multiple keys from Dictionary while Iterating ?
In this article we will discuss how to remove multiple key / value pairs from dictionary while iterating. Suppose we have a dictionary of string and int i.e. Advertisements # Dictionary of strings wordFreqDic = { “Hello”: 51, “at” : 23 , “test” : 33, “here” : 63, “start” : 13 } Now we want …
Python : How to Remove multiple keys from Dictionary while Iterating ?Read More
How to change current working directory in python ?
In this article we will discuss how to change the current working directory in python. Current working directory is the directory in which program is running. Advertisements Change Current Working Directory in Python First of all we need to import python’s os module i.e. import os Python’s os module provides a function to change the …
How to change current working directory in python ?Read More