Getting back into programming, I’ve been messing with this for a while now sure it’s something super simple or maybe I have things set-up completely wrong.
It’s an issue with it not iterating over the rest of the list.
So whenever you run the code you enter a file extension i.e. "File.jpg" and it comes back with image, but if you enter any of the other image types it returns application.
def main():
file = input("File name:")
extension(file)
def extension(s):
split = (s.split("."))
join_s = (''.join(split[1]))
image_e = ['jpg', 'gif', 'jpeg', '.png']
for i in image_e:
print(image_e)
if i == join_s:
return print("Image/")
else:
return print("Application")
main()
I haven’t got to the part of implementing the application formats just yet, but I am sure once I figure this bit out it shouldn’t be any sort of issue.
>Solution :
Change your if statement to "if join_s in image_e:" should work. Also,"png" inside image_e should not have a "." infront of it