You are here: Home / Topics / Python program to accept a filename from the user and print the extension of that

Python program to accept a filename from the user and print the extension of that

Filed under: Python on 2023-09-18 06:56:06

filename = input("Input the Filename: ")
f_extns = filename.split(".")
print ("The extension of the file is : " + repr(f_extns[-1]))     

Output:

Input the Filename: abc.java                                                                                  
The  extension of the file is : 'java' 

About Author:
S
Shyam Dubey     View Profile
If you are good in any field. Just share your knowledge with others.