Write a python program that splits a sentence into words

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tharun03
    New Member
    • Oct 2021
    • 1

    Write a python program that splits a sentence into words

    Hi
    I don't have much experience on python coding. Can someone give me a answer for this ques.
    Question: Write a python program that splits a sentence into words. Change the first and last letter of each word into uppercase and display them.
    For example if we type input as hello,world
    The output must be:
    HellO
    WorlD
  • dev7060
    Recognized Expert Contributor
    • Mar 2017
    • 656

    #2
    Hi
    I don't have much experience on python coding. Can someone give me a answer for this ques.
    Question: Write a python program that splits a sentence into words. Change the first and last letter of each word into uppercase and display them.
    For example if we type input as hello,world
    The output must be:
    HellO
    WorlD
    What have you done so far?

    Comment

    • SioSio
      Contributor
      • Dec 2019
      • 272

      #3
      Code:
      import re
      txt = 'hello,world hello/world hello+world hello-world'
      new_word = []
      for word in re.split('[ ,+-/]',txt):
          new_word = word[0].upper() + word[1:len(word)-1] + word[len(word)-1].upper()
          print (new_word)

      Comment

      • Vanisha
        New Member
        • Jan 2023
        • 26

        #4
        Here's a simple Python program that uses the split() method to split a sentence into words:
        sentence = input("Enter a sentence: ")

        words = sentence.split( )

        print("The words in the sentence are:")
        for word in words:
        print(word)
        If you're looking to improve your coding skills or learn new technologies, join Cetpa Infotech.
        Check out our website for more information.

        Comment

        • Roman123456789
          New Member
          • Mar 2023
          • 3

          #5
          why don't you contact Pytnon developers right away? I value my time and I will leave such small tasks for https://lomray.com/. At the same time, you will gain experience on how you could solve this problem.

          Comment

          Working...