Reverse a string if its length is multiple of 4

In this program, we will take a string as input and reverse a string if its length is a multiple of 4

Steps to solve the program
  1. Take a list as input.
  2. If its length is divisible by 4 then reverse the string.
  3. Print the output.
				
					#Input string
string = "sqatools"

if len(string) % 4 == 0:
    print(string[::-1])
				
			

Output :

				
					slootaqs
				
			

string made of 4 copies of the last two characters

count occurrences of a substring in a string.

Leave a Comment