in extensions.py all of my check50 works except for 😦 input of myfile, with no extension, yields output of application/octet-stream expected "application/oc...", not "". at the moment my code reads
filename = input("File Name: ")
filename = filename.strip()
if filename.endswith("gif"):
print("image/gif", end = "")
if filename.endswith("jpg"):
print("image/jpeg", end = "")
if filename.endswith("jpeg"):
print("image/jpeg", end = "")
if filename.endswith("png"):
print("image/png", end = "")
if filename.endswith("bin"):
print("application/octet-stream", end = "")
if filename.endswith("pdf") or filename.endswith("PDF"):
print("application/pdf", end = "")
if filename.endswith("txt"):
print("text/plain", end = "")
if filename.endswith("zip"):
print("application/zip", end = "")
#if filename.endswith(""):
#print("application/octet-stream", end = "")
in order to fix the error I uncomment the last lines saying endswith("") so the final line reads
if filename.endswith(""):
print("application/octet-stream", end = "")
but if I do that check50 yields the opposite results as every test fails except the last one that I was trying to fix. Why does every other test fail when I fix the problem?
check50 results with final 2 lines commented out
🙂 extensions.py exists
🙂 input of cs50.gif yields output of image/gif
🙂 input of happy.jpg yields output of image/jpeg
🙂 input of happy.jpeg yields output of image/jpeg
🙂 input of check.png yields output of image/png
🙂 input of document.pdf yields output of application/pdf
🙂 input of plain.txt yields output of text/plain
🙂 input of files.zip yields output of application/zip
🙂 input of application.bin yields output of application/octet-stream
🙂 input of document.PDF yields output of application/pdf
🙂 input of document.PDF, with spaces on either side, yields output of application/pdf
🙂 input of test.txt.pdf, with one extra extension, yields output of application/pdf
🙂 input of zipper.jpg, with another extension name, yields output of image/jpeg
😦 input of myfile, with no extension, yields output of application/octet-stream
expected "application/oc...", not ""
check50 results with final 2 lines included
🙂 extensions.py exists
😦 input of cs50.gif yields output of image/gif
expected "image/gif", not "image/gifappli..."
😦 input of happy.jpg yields output of image/jpeg
expected "image/jpeg", not "image/jpegappl..."
😦 input of happy.jpeg yields output of image/jpeg
expected "image/jpeg", not "image/jpegappl..."
😦 input of check.png yields output of image/png
expected "image/png", not "image/pngappli..."
😦 input of document.pdf yields output of application/pdf
expected "application/pd...", not "application/pd..."
😦 input of plain.txt yields output of text/plain
expected "text/plain", not "text/plainappl..."
😦 input of files.zip yields output of application/zip
expected "application/zi...", not "application/zi..."
😦 input of application.bin yields output of application/octet-stream
expected "application/oc...", not "application/oc..."
😦 input of document.PDF yields output of application/pdf
expected "application/pd...", not "application/pd..."
😦 input of document.PDF, with spaces on either side, yields output of application/pdf
expected "application/pd...", not "application/pd..."
😦 input of test.txt.pdf, with one extra extension, yields output of application/pdf
expected "application/pd...", not "application/pd..."
😦 input of zipper.jpg, with another extension name, yields output of image/jpeg
expected "image/jpeg", not "image/jpegappl..."
🙂 input of myfile, with no extension, yields output of application/octet-stream