Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

while replacing the input string spaces with underscore and then checking it it does not replaces

    game=input("enter student name to update report card: ")
    nn=game.replace("  ", "_")
    mycursor.execute("show tables")
    klm = mycursor.fetchall()
    if (nn,) in klm:
        b=int(input("enter sno: "))
        mycursor.execute("select * from {} where sno='{}'".format(nn,b))
        xer=mycursor.fetchall()
            
    else:
        print("no student record found")

this does not execute the if statement it directly goes to the else even though i have table name some_one, it shows no record found

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

nn=game.replace(" ", "_") has 2 spaces in your code

Try with

nn=game.replace(" ", "_") has one space

game=input("enter student name to update report card: ")
nn=game.replace(" ", "_")
print(nn)
#output
enter student name to update report card: some one
some_one
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading