Nov-15-2022, 04:58 PM
(This post was last modified: Nov-15-2022, 05:31 PM by Yoriz.
Edit Reason: Title
)
Hello.
I'm sorry to bother you all, but I'm having trouble with the While loop, and the Quit function. I've tried it before, but I didn't get it to work, unfortunately. But I want it to work now. I'm ready to learn!
So, here's the code (with comments), and I don't know what to do with it:
Why does Python do this? Is there any workarounds? I'm in week 8 of learning it, and I just don't get why it does this.
If there are any workarounds, please can I see them? Because this is important to me.
I hope you all understand.
Thank you!
I'm sorry to bother you all, but I'm having trouble with the While loop, and the Quit function. I've tried it before, but I didn't get it to work, unfortunately. But I want it to work now. I'm ready to learn!
So, here's the code (with comments), and I don't know what to do with it:
quit = False # New boolean value to check if the user wants to quit or not. while quit == False: # While Loop to check if quit is False, then carry on input_edq = input('Pres the letter "E", then press enter to encrypt text, press the letter "D", then press enter to decrypt text and press the letter "Q", then press enter to exit: ') # Input the text E, D or Q. If the user wants to not enter the correct letter, see below... if input_edq == "q" or "Q": print("You're exiting the program. Farewell!") quit = True if quit == True: exit() if input_edq == "e" or "E": message = str(input('Enter a message ')) shift = int(input('Enter a shift number ')) if input_edq == "d" or "D": message = str(input('Enter a message ')) shift = int(input('Enter a shift number ')) else: input_edq = input('Invalid response! Pres the letter "E", then press enter to encrypt text, press the letter "D", then press enter to decrypt text and press the letter "Q", then press enter to exit: ') # If it's anything but the valid response, then print this out and input new command.So, you see I only want it to quit when the user inputs "q" or "Q", however that's not the case. It quits automatically, whenever I input anything.
Why does Python do this? Is there any workarounds? I'm in week 8 of learning it, and I just don't get why it does this.
If there are any workarounds, please can I see them? Because this is important to me.
I hope you all understand.
Thank you!