How can I make this more complex?
MRAB
python at mrabarnett.plus.com
Mon Nov 9 19:00:33 EST 2020
On 2020-11-09 21:04, Quentin Bock wrote:
> grade = input("Enter your grade: ")
> if grade >= 90:
> print("You got an A ")
> if grade >= 80:
> print("You got a B ")
> if grade >= 70:
> print("You got a C")
> if grade >= 60:
> print("You got a D ")
> if grade >= 50:
> print("You failed")
>
>
>
>
> How can I make this to say if your grade is 90 or higher BUT less than 100
> you got an A,
>
In addition to other the answers, you should note that the 'input'
function returns a string, so you'll need to convert that string to a
number, most probably by using 'int', and, ideally, print a helpful
message if that raises ValueError because it's not a valid number.
More information about the Python-list
mailing list