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:
M
Mr. Dubey     View Profile
Founder of MCQ Buddy. I just like to help others. This portal helps students in getting study material free. Share your stuff here so that others can get benefitted.