mardi 28 mai 2019

My function based on user input and if/else statements gives the same output no matter the user input

I get the same output no matter what the user input is. The main python file I'm working from calls on the function from a secondary file.

I've tried changing the if else statement conditions but I keep having the same issue.


if __name__ == '__main__':
    import No_2   

    No_2.cont()

    print('File1: This would be a good place to continue data manipulation.')
    input("Press the enter key to close")

And here is No_2


def cont():
    import sys

    c = input('File2: Would you like to continue? ')
    if c == 'Y' or 'y':
        print('File2: Ok we\'ll carry on...')
        print(' ')
        return

    else: sys.exit()

I expect the script to close when C does not = Y or y... Where as I would like it to return to the main script if the input is Y or y.

Aucun commentaire:

Enregistrer un commentaire