Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If-Else statements issue
#1
hello there ,
first of all i'm all new to this language , and all my knowledge this far in computing comes from C .

my issues are with this code lines :
----------------------------------------------------
answer=input("would you like to proceed Y/N ? ")

if answer == "N" or "n" :
    print("too bad ,thank you {} see you again ".format(users_name))
elif answer == "Y" or "y":
    print("great !")     
----------------------------------------------------
the problem is , by getting from the users "Y" or "y" the condition that happens is the first one , which should happen by getting "N" or "n" .more then that, by getting some other char that is not N,n,Y,y the result is again the first messege .
putting Parenthesis: answer == ("N" or "n") doesnt completly solve the problem .
what's wrong with those lines ? is it a syntax problem ?
how do i solve it ? Tongue
Reply
#2
https://python-forum.io/Thread-Multiple-...or-keyword
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
thank you so much !
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020