Hi I'll keep this as succinct as possible.
I'm new to coding, I want to create a database that identifies the extension of a filename the user inputs and matches it to the mother/father language.
e.g) The user inputs the filename: math.py
Output:
The extension 'py' is Python.
I wrote up if statements for each extension but the code won't go past the 2nd condition. Are my indentations incorrect? What's causing the program to stop working at the 2nd if statement? Is there a more efficient way?
filename = input("Please enter the filename: ")
extension = filename.split(".")
extension = repr(extension[-1])
if extension == "'asp'":
print("The extension " + extension + " is ASP Classic.")
elif extension == "'aspx'" or "'axd'" or "'asx'" or "'asmx'" or "'ashx'":
print("The extension " + extension + " is ASP.net.")
elif extension == "'css'":
print("The extension " + extension + " is CSS.")
elif extension == "'cfm'":
print("The extension " + extension + " is Coldfusion.")
elif extension == "'yaws'":
print("The extension " + extension + " is Erlang.")
elif extension == "'swf'":
print("The extension " + extension + " is Flash.")
elif extension == "'html'" or "'htm'" or "'xhtml'" or "'jhtml'":
print("The extension " + extension + " is HTML.")
elif extension == "'jsp'" or "'jspx'" or "'wss'" or "'do'" or "'action'":
print("The extension " + extension + " is Java.")
elif extension == "'js'":
print("The extension " + extension + " is Javascript.")
elif extension == "'pl'":
print("The extension " + extension + " is Perl.")
elif extension == "'php'" or "'php4'" or "'php3'" or "'phtml'":
print("The extension " + extension + " is PHP.")
elif extension == "'py'":
print("The extension " + extension + " is Python.")
elif extension == "'rb'" or "'rhtml'":
print("The extension " + extension + " is Ruby.")
elif extension == "'shtml'":
print("The extension " + extension + " is SSL.")
elif extension == "'xml'" or "'rss'" or "'svg'":
print("The extension " + extension + " is XML.")
else:
print(extension + " This extension isn't in the database.")