mardi 11 juillet 2017

My if elif code is ignoring the elif part.

Here is part of my code that has the if elif statement. For some reason the code outputs the if statement when called but ignores the elif when called. Please help:

if cv2.waitKey(1) == 32: # 32 is also equal to spacebar. 
elif cv2.waitKey(1) == 27: # 27 is equal to escape
    name = input("Name the file:")
    testimage = ("'%s'.jpg".format(img_counter) %name) 
    cv2.imwrite(testimage, frame)
    print("Picture saved!")
    img_counter += 1
    choice = input("Do you want to post to facebook?(Y/n)")
    if choice == 'Y':
        print("Posting now!")
    elif choice == 'n':
        print("Ok not posting.")

Aucun commentaire:

Enregistrer un commentaire