lundi 9 novembre 2015

Look at length of file type and determine what type of file is being opened

working on a program that takes a file and determines what type it is. It must be a .wav or .jpg file to be correct, and if it is not one of those, it will display a message that says to choose a correct file type. However, I am stuck on how to get it to determine what type of file is being chosen, since for this program I am not allowed to use f.endswith(), so I was thinking range may work but I am unsure what the paramaters should be, or if range is even the correct choice for how to determine the file type. help please :)

def fileType():

f = pickAFile print f for f in range (): start = f.rfind(".") if start!=-1:

        print A .wav file type was selected

        print A .jpg file type was selected
    else:
      print No file type was chosen
      print Please choose a different file type

Aucun commentaire:

Enregistrer un commentaire