def main ():
list1 = input("Please input the list of words to evaluate: ")
longest = max(list1.split(),key = len)
print ("The longest word is", longest, "length =", len(longest))
main()
Please input the list of words to evaluate: banana apple aeroplane The longest word is aeroplane length = 9
def remove_char(str, n):
first_part = str[:n]
last_part = str[n+1:]
return first_part + last_part
print(remove_char('Jupyter', 0))
print(remove_char('Jupyter', 3))
print(remove_char('Jupyter', 5))
upyter Jupter Jupytr
str1 = 'https://scde.jntuh.ac.in/lmsportal/participant/home-index'
print(str1.rsplit('/', 1)[0])
print(str1.rsplit('-', 1)[0])
https://scde.jntuh.ac.in/lmsportal/participant https://scde.jntuh.ac.in/lmsportal/participant/home
def sortLexo(my_string):
words = my_string.split()
words.sort()
for i in words:
print( i )
if __name__ == '__main__':
my_string = "hello this is example how to sort " \
"the word in alphabetical manner"
sortLexo(my_string)
alphabetical example hello how in is manner sort the this to word
def remove(string):
return string.replace(" ", "")
string = ' P y t h o n '
print(remove(string))
Python