Write a Python Program to Read Any String and print the middle character of it

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

Thank you All!!! Hope you find this useful.


Up ↑

%d bloggers like this: