I want to get the grades of student based on there marks, while using for and if i can use break when the first time numbers are greater the specified grade the program is
numb = int(input("Enter the numb:"))
my_dict = {90: 'A+', 80: 'A', 70: 'B', 60:'C'}
for gr in my_dict.keys():
if numb > gr:
grade = my_dict.get(gr)
break
print(grade)
I want to implement it using list comprehension
Any suggestion don't want to import any modules just using basic python
this is what i wrote:
grade = [my_dict.get(gr) for gr in my_dict.keys() if numb > gr ]
but this would obviously give me a list of all grades when number are greater than specific value of number.