Niharikaa Aitam has Published 93 Articles

Generate two output strings depending upon occurrence of character in input string in Python

Niharikaa Aitam

Niharikaa Aitam

Updated on 20-Jun-2025 19:19:22

148 Views

In Python, a string is one of the data structures that is a sequence of characters enclosed within single quotes '' or double quotes "". It is immutable, i.e., once a string is created, it cannot be changed. When we want to generate two output strings based on character occurrence ... Read More

To print all elements in sorted order from row and column wise sorted matrix in Python

Niharikaa Aitam

Niharikaa Aitam

Updated on 20-Jun-2025 19:18:12

262 Views

In Python, we may go through the matrices that are sorted in a particular order. A common case is a matrix where each row and each column is sorted in increasing order, and this does not mean that the entire matrix is sorted. In such cases, we need to ... Read More

How to copy a file to a remote server in Python using SCP or SSH?

Niharikaa Aitam

Niharikaa Aitam

Updated on 20-Jun-2025 19:16:33

16K+ Views

When we want to transfer files from our local system to a remote server securely, Python provides possible ways to do the file transfer using the Paramiko and SCP libraries. These libraries support SSH-based file transfer, which is secure and reliable. Installing Required Libraries Before we start with file transfer, ... Read More

How to perform different commands over ssh with Python?

Niharikaa Aitam

Niharikaa Aitam

Updated on 20-Jun-2025 19:15:44

2K+ Views

When we want to remotely access and execute commands on another machine then we use the paramiko library in Python. Paramiko is a third-party library that is used to connect and communicate securely with remote machines using the SSH, i.e., Secure Shell protocol. It allows us to execute commands, transfer ... Read More

How to print Python dictionary into JSON format?

Niharikaa Aitam

Niharikaa Aitam

Updated on 20-Jun-2025 19:07:27

8K+ Views

In Python, Dictionaries are used to store structured data. When we want to print this data in a human-readable format or transfer it through the internet, such as to an API, then we need to convert the dictionary to JSON, i.e., JavaScript Object Notation. Python has a built-in module ... Read More

How to merge multiple Python dictionaries?

Niharikaa Aitam

Niharikaa Aitam

Updated on 20-Jun-2025 18:57:20

343 Views

In Python, a dictionary is a collection of key-value pairs that is used for data retrieval. In some cases, we may need to combine two or more dictionaries into one. This is known as merging dictionaries. In this article, we will explore different methods to merge multiple dictionaries in ... Read More

Python - Check if all elements in a List are same

Niharikaa Aitam

Niharikaa Aitam

Updated on 20-Jun-2025 18:37:26

28K+ Views

In Python, a list is a collection of ordered and mutable elements enclosed in square braces[]. Each element in a list has a unique position index, starting from 0. It can accept duplicate elements. In some cases, we may need to check if all the elements in a list ... Read More

How to insert new keys/values into Python dictionary?

Niharikaa Aitam

Niharikaa Aitam

Updated on 11-Jun-2025 15:26:06

65K+ Views

A dictionary in Python is a mutable, unordered collection of key-value pairs.Inserting keys/values into a Python dictionaryWe can add new key-value pairs to an existing dictionary simply by assigning a value to a new key. In this article, we are going to explore the different ways to insert new key ... Read More

How to extract all the .txt files from a zip file using Python?

Niharikaa Aitam

Niharikaa Aitam

Updated on 10-Jun-2025 18:29:03

2K+ Views

Python provides a built-in module called zipfile that allows us to create, read, write, and extract ZIP archives. When we want to extract only specific files, such as all .txt files, then we can perform filtering of the file names using string methods such as endswith(). A ZIP file is ... Read More

How to truncate a Python dictionary at a given length?

Niharikaa Aitam

Niharikaa Aitam

Updated on 10-Jun-2025 17:47:50

3K+ Views

Truncating a dictionary in Python means limiting it to a fixed number of key-value pairs. From version Python 3.7 onwards, the dictionaries store the values based on the insertion order, which makes it easy to slice and rebuild a smaller dictionary using the first N items. This is helpful when ... Read More

Advertisements