My code:
def check_File_Type(self):
suffix={"docx","pptx","xlsx"}
if [self.file_path.endswith(x) for x in suffix]:
print(x)
what I wanna do is to return the file type if it is one of those in suffix. but I get the error "NameError: global name 'x' is not defined". seems like I can't use "x" since it's in the [statement]? then how can I print the x here?
thanks
xyou want to print? Do you want to print the suffix the path ends with?