Category Archives: Python Programs

Check if given string contains Even 1’s and Odd 0’s

In this problem a string is given, our task is to check the string contains even number of 1’s and odd number 0’s or not. Examples: Input : “101010100” Output : Accept Input : “111001010101” Output : Not Accept Approach used in function: we firstly declare set s which contain ‘0’ and ‘1’ and create set of the… Read More »

Find Words containing ‘a’ in given String

Given a statement(string), the task is to check if that string contains any word which contains ‘a’ in it then print that word otherwise print no any word containing ‘a’ in the inputed string. Examples : Input: “W3Colleges provides excellent tutorials” Output: tutorials Input: “Python is fun” Output: no any word containing ‘a’ in the inputed string Input:… Read More »

Check if given string is Binary string

In this problem a string is given, our task is to check the string is binary string or not. Examples:  Input : ‘01010101010’ Output : Accepted Input : ‘w3colleges101’ Output : Not Accepted # 1st method : This approach used in function: we firstly create set of the characters present in the given string using set() function and… Read More »

Python Program to Swap String Case Without Using swapcase()

Generally, we use swapcase() to swap strings in Python. What if we are asked to do swapping without using the method. In this article, I will be sharing python program to swap upper case letters to lower case and vice versa in the same string. Examples: Input: “w3ColLeges” Output: “W3cOLlEGES” Input: “W3cOlLegEs OrG” Output: “w3CoLlEgEs oRg” Some  letters… Read More »