In this post, we will write a simple Python code that will read any string and print the middle character from it. We will write the code and also show the output.
Code
name = input("Enter your name - ")
def middle_charracters(name):
return name[(len(name)-1)//2:(len(name)+2)//2]
print(middle_charracters(name))
Output
Enter your name - Jd Technologies
n