Write a Python program to accept a filename from the user print the extension of that. Example :- Enter filename: hello.java output: java

 a=input("Enter any file name with extension : ") ''' Accept from user '''

e=' '  ''' e is empty string '''

flag=False

if '.' in a:

    for i in a:

        if i=='.':   ''' if  (.) is found in filename then add characters in e ''' 

            flag=True

        elif flag==True:

            e=e+i

    print(e) ''' print extension '''

0 Comments