# Python function that takes a list of words and return the longest word and the length of the longest one.
def Longest(a):
word1 = len(a[0])
lenght = a[0]
for i in a:
if(len(i) > word1):
word1 = len(i)
lenght = i
print("The longest word is", lenght, ", with length of", word1,"words")
a = str.split(input("Enter the words which you want to measure with spaces:"))
Longest(a)
The longest word is koushik , with length of 7 words
# Python function to remove the nth index character from a nonempty string.
def remove(enter_word, n):
enter_word2 = enter_word[:remove_number]
enter_word3 = enter_word[remove_number+1:]
return enter_word2 + enter_word3
enter_word = input("Enter the word :")
remove_number = int(input("Enter the index of the character to remove starting from 0 :"))
print("The word you entered is :",enter_word)
print("The number of word you want to remove is :", remove_number)
print("You orderd word is :", remove(enter_word , remove_number))
The word you entered is : koushik The number of word you want to remove is : 0 You orderd word is : oushik
# Python function to get the last part of a string before a specified character.
orginal_string = "How are you today!"
splited_string = orginal_string.split(" ")
print(splited_string)
before_specific_character = splited_string[3]
print(before_specific_character)
['How', 'are', 'you', 'today!'] today!
# Python function to sort a string lexicographically.
orginal_list = ["kiran","mikel","saida","koushik","alex"]
orginal_list.sort()
print ("Your list in lexicographical order : ",orginal_list)
Your list in lexicographical order : ['alex', 'kiran', 'koushik', 'mikel', 'saida']
# Python function to remove spaces from a given string.
native_string = str(input("Enter some strings with spaces:"))
print(native_string, ",is the string you have given")
modified_string = native_string.replace(" ","")
print(modified_string, ",is the modified string")
koushik reddy how are you ,is the string you have given koushikreddyhowareyou ,is the modified string