Coders Packet

Replacing First Element with Middle Element of a String in Python

By VenkatNarayan.K

  • pgm3.py
  • Replacing-first-element-with-middle-element-python.docx
  • outputss.png
  • Python Program to remove the middle element of a string which is got from the user and replacing the first element with that middle element

    A String is given as an input and the middle element of a string is found. The middle element is identified by performing floor division to the length of the string. For an unequal string length, the element which is close to the centre is taken as the middle element. The next step is replacing the first element with the identified middle element. The output string is displayed with the first letter altered. This program works for both lowercase and uppercase characters. 

    Download Complete Code

    Comments

    Comments for the packet "Replacing First Element with Middle Element of a String in Python";
    No comments yet