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

Issue with running input and if/else code in a single code

Please don’t hate me if something like this has been asked, I couldn’t find a similar problem.
I’m learning python, and I’m trying to get a small piece of code to work in IDLE shell 3.9.7 like this

>>> mark=int(input("enter mark"))
    if mark>=90:
        print("excellent")
    elif mark<90 and mark>=75:
        print("good")
    elif mark<75 and mark>=40:
        print("average")
    else:
        print("fail")

with the idea that you enter the mark, then it prints one of the statements without having to run the input code then the if/elif/else statements afterwards (I want to have all this code, press enter and then get the desired input/output without running the if/else statements separately.) However, when I run the code, I enter the mark and nothing happens. I’ve tried different indentation and putting the input bit at the end, but it just asks for the mark and then nothing happens. I’m not sure what I’m doing wrong, as the app that I’m using to learn has it parsed exactly like this. Appreciate any help.

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 :

Try this it should work just had to put it in a for loop

while True:
    mark=int(input("enter mark: "))
    if mark>=90:
        print("excellent")
    elif mark<90 and mark>=75:
        print("good")
    elif mark<75 and mark>=40:
        print("average")
    else:
        print("fail")
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