Skip to content
Snippets Groups Projects
Commit 2a701f3c authored by Ganesh's avatar Ganesh
Browse files

hi

parent 17425089
No related branches found
No related tags found
No related merge requests found
def depth(s, n):
current_max = 0
final_max = 0
for i in range(n):
if s[i] == '(':
current_max += 1
if current_max > final_max:
final_max = current_max
elif s[i] == ')':
if current_max > 0:
current_max -= 1
else: #unbalanced
return -1
if current_max != 0: #unbalanced
return -1
return final_max
s = input()
print (depth(s, len(s)))
s = str(input())
for i in range(97, 123):
v = s.count(chr(i))
if(v>0):
print(chr(i) + ": " + str(v))
s = list(input())
for i in range(1, len(s)):
if(s[i] == s[0]):
s[i] = "$"
s = "".join(s)
print(s)
a = input("Enter the first string")
x = a[:2]
x1 = a[2:]
b = input("Enter the Second String")
y = b[:2]
y1 = b[2:]
print (y+x1+" "+x+y1)
str=["PHP", "Exercises", "Backend"]
c=max(str,key=len)
print(c)
str = "Ganesh"
print(str.upper())
print(str.lower())
n=input("Enter the String :")
if len(n)%4 == 0:
print(n[::-1])
def encrypt(string, shift):
cipher = ''
for char in string:
if char == ' ':
cipher = cipher + char
elif char.isupper():
cipher = cipher + chr((ord(char) + shift - 65) % 26 + 65)
else:
cipher = cipher + chr((ord(char) + shift - 97) % 26 + 97)
return cipher
s= input("String: ")
shift = int(input("Shift: "))
print("Encrypted String: ", encrypt(s, shift))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment