###1.Fuction to take in a list of words, find the longest word and print the length of the longest word
string=input("Enter a list of names separated by , : ")
list=string.split(",")
largest=0
for i in list:
if len(i)>largest:
largest=len(i)
j=i
print("The longest word is", j, "and it is", largest, "letters long")
Enter a list of names separated by , : Sumanka,Rahul,Siya,vani The longest word is Sumanka and it is 7 letters long
###2. Function to remove the nth index character from a non empty string
mystr=str(input("Enter a String:"))
n=int(input("Enter the nth character to be removed: "))
new_string=""
for i in range(0,len(mystr)):
if (i!=n-1):
new_string=new_string+mystr[i]
print("The new string is", new_string)
###3. Function to get the last part of a string before a specified character
Mystr=str(input("Enter a string: "))
n=int(input("Enter the nth character: "))
new_str=""
for i in range(0,len(Mystr)):
if i>n-1:
new_str=new_str+Mystr[i]
print("New string is", new_str)
Enter a string: Sumanka Enter the nth character: 3 New string is anka
###4. Function to sort a string lexicographically
My_str=str(input("Enter a String: "))
New_str=sorted(My_str)
lex=""
for char in New_str:
lex=lex+char
print("The lexicographical order of", My_str, "is", lex)
Enter a String: sumanka The lexocographical order of sumanka is aakmnsu
###5. Function to remove spaces from a given string
My_str=str(input("Enter a string: "))
New_str=My_str.replace(" ","")
print(New_str)
Enter a string: My name is Sumanka MynameisSumanka