#
def word_list(items):
y=0
max_len=0
str=""
for x in items:
y=len(x)
if y>max_len:
max_len=y
str=x
# print("count=",count,"str=",str)
return str,max_len
word_list(['a1','c23','f466'])
('f466', 4)
#remove the nth index character from a non empty string
def rem_str(n):
str="FUNCTION_ARE_IMPORTANT"
new_str=" "
l1=len(str)
new_str=str[0:n]+str[n+1:]
print("Original String=",str," OriginalString length=",len(str))
print("Modified String=",new_str," String length=",len(new_str))
rem_str(2)
Original String= FUNCTION_ARE_IMPORTANT OriginalString length= 22 Modified String= FUCTION_ARE_IMPORTANT String length= 21
#Function to get a last part of the string before a specified character
def spl_char(c1):
cnt=0
str="ABCDEFG"
cnt=str.find(c1)
print(str[:cnt])
spl_char('E')
ABCD
#Program to sort a string lexographically
str=['c','v','m','g','u','e']
str1=str,str.sort()
print(str1)
(['c', 'e', 'g', 'm', 'u', 'v'], None)
#Program to remove spaces from a given string
str="HYDERABAD IS A BEAUTIFUL CITY"
str1=str. replace (" ","")
print(str1)
HYDERABADISABEAUTIFULCITY