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

Python match statment and using input to feed it?

I’m trying to use the new match statementbut am running into some problems the following code doesn’t work as expected, as usual i’m certain i’m doing somthing stupid can anyone point out what it is?

inputstring = ""
while (inputstring.upper != "Q"):
    inputstring = input("Enter selection without the full stop:")
    match inputstring.upper:
        case "H":
            printtoolsmenu()
        case "1":
            pass
Enter selection without the full stop:H
Enter selection without the full stop:h
Enter selection without the full stop:h
Enter selection without the full stop:H
Enter selection without the full stop:"H"
Enter selection without the full stop:

>Solution :

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

As the comment pointed out you need to add parenthesis to actually call upper:

match inputstring.upper():
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