Working on a beginners project after a long time i didn't code, so my apologies for this lazy ass coding. :)
The Project is in Python 3.7 and i'm coding um Pycharm.
Well my question is simple, the if statement is clearly saying pass the if statement only if the String is equals to "Y" or "y", but as you can see that the character "n" is passing the statement as well.
I've searched in python documentation ( 5 min search) and couldn't find anything worthwhile, so i'm lazy and hoping that one of you crazy ass geniuses could teach me a new thing. :)
also I've tried rewriting the code a few times but this thing just stuck in my mind and i really want to understand as to why this is happening
'''
User_Answer = True
while User_Answer:
User_Answer = input("## Do you want to enter a student? Y/N: ")
if User_Answer == "y" or "Y":
student_name = input("## Enter Student Name: ")
student_id = input("## Enter Student ID: ")
add_student(student_name, student_id)
print_students_titlename()
elif User_Answer == "N":
break
'''
OUTPUT_________________________________________________
Do you want to enter a student? Y/N: n
Enter Student Name:
Thanks in advance to anybody trying to help
Aucun commentaire:
Enregistrer un commentaire