Python – Find String Length

Python Program to Find Length of a String Q. Write a Python program to take user input and calculate length of a string. Use built in len() Python function to calculate the length of a string. This function take one argument of type object. If the input object is a string, this function will calculate length of a string. Example:

Output 8 Example with User Input Another Python program to take input of string from user and calculate the length.

Execute above Python script. enter a string when…

Read More

Python – Compare Two Strings

Check If Two Strings Are Equal using Python Use == operator to test if two given strings are equal or not. You can use != as not equal to operator. It returns false if string matches. Example In this example, we initialize two variable with sting and compare if both stings are equal or not.

Output: Equal Another Example Here is another sample Python program which will prompt user to enter a strings. Then compare the input string with another predefined string.

Read More

Python – Concatenate Two Strings

Python Program to Concatenate Two Strings Write a Python program to concatenate two string and print the result. Also create a example to take user input of two strings and concatenate and print the result. Using + symbol to concatenate two different strings together and get result string. Example A sample Python program to assgin static string to two variables and then concatenate. Then print the result string with print() function.

Another example to take input from user and concatenate them.

Read More

String to UPPERCASE

How to Convert A String To Uppercase in PHP The PHP strtoupper() function is used to convert a string to uppercase. Try the below example to under the working of this function, which convert all alphabets of a string to uppercase. Example:

Output: WELCOME TO TECADMIN.NET

Read More

Combine Two Strings

How to Combine Two Strings in PHP The PHP programming language uses dot (.) operator to create singe string by combining two strings. This operator is specifically designed for strings. You can use this operation in multiple ways. Example 1:

You can also concatenate one string and other string variable. For example:

You can also concatenate with assignment operator (‘.=’), which appends the argument on the right side to the argument on the left side. For example:

Read More

Python – Strings

Python Strings A string is a sequence of characters and a character is can be a alphabet, digit or symbol. The Python treated any sequence of character’s enclosed in quotes as a string.

Python treated both single and double quted sequence as string. But in results of any string will be in a single quote only. like: ‘Welcome’ String Concatenation In Python strings have operation symbols too. Using a plus (+) symbol concatenate two strings. let’s type below example on Python shell.

The result will be same ‘Hello…

Read More

Concatenate string variables

Brief: This example will help you to concatenate two or more strings variable in a bash script. This tutorial helps you with multiple shell script examples of concatenating strings in a shell script. The first example is a general way to concatenate variables of string. You can simply write all the variable one after another:

Output: Welcome TecAdmin! Another Example You can also use += operator to concatenate two strings and store results in the first string.

Output: Welcome TecAdmin! One More Example Use another example with one…

Read More

Check if two strings are equal?

Bash – Check If Two Strings are Equal Brief: This example will help you to understand to check if two strings are equal in a bash script. This shell script accepts two string in variables and checks if they are identical. Details Use == operator with bash if statement to check if two strings are equal. You can also use != to check if two string are not equal. You must use single space before and after the == and != operators. Example In this script two variables are initialized…

Read More

Bash – String Comparisons

Bash String Comparisons Use double equals ( == ) operator to compare strings inside square brackets []. Using this option you simply test if two given strings are equals or not inside bash shell scripts. Example Syntax: if [ “$str1” == “$str2” ] # True if equal if [ “$str1” != “$str2” ] # True if not equal Example: For example to compare two string are equal or not. if [ “hello” == “hello” ] ## True if [ “hello” == “hello1” ] ## False if [ “hello” != “hello”…

Read More