Skip to content

Instantly share code, notes, and snippets.

@SaikumarKonakanchi0
Created July 22, 2023 17:12
Show Gist options
  • Save SaikumarKonakanchi0/4d444971424ec5e63ac01d0dc32e5d94 to your computer and use it in GitHub Desktop.
Save SaikumarKonakanchi0/4d444971424ec5e63ac01d0dc32e5d94 to your computer and use it in GitHub Desktop.
22-07-2023
def ex_str(n):
a=n[0]
b=n[-1]
print(b+n[1:-1]+a)
n=input()
ex_str(n)
#Expected Output for string Germany
#yermanG
def long_str(n):
long_string=n[0]
for i in n:
if len(i)>len(long_string):
long_string=i
return long_string
n=["apple", "banana", "kiwi", "orange", "grapefruit"]
print('Longest String is:',long_str(n))
#Expected Output:
#Longest String is: grapefruit
def no_of_words(n):
print('The no of words in the sentence are:',len(n))
n=input('Enter the sentence with words seperated by spaces: ')
res=n.split()
no_of_words(res)
#Expected Output:
# Enter the sentence with words seperated by spaces: Germany is a beautiful city
# The no of words in the sentence are: 5
def palindrome(n):
if n==str(n[::-1]):
print('Palindrome')
else:
print('Not Palindrome')
n=input('Enter the String: ')
palindrome(n)
def remove_vowels(n,remove):
res=''
for i in n:
if i not in remove:
res+=i
print(res)
n=input('Enter tne string: ')
remove='aeiou'
remove_vowels(n,remove)
#Expected Output:
# Enter tne string: Germany
# Grmny
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment