I have a problem with my code. For example, when I type in something that’s not in the dictionary( for example: G), it prints “invalid input. Retry again” . After I type in (for example: A), it prints “invalid input” again even though it’s in the dictionary. I’m not sure why this happens. Could you fix this code?

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question
I have a problem with my code. For example, when I type in something that’s not in the dictionary( for example: G), it prints “invalid input. Retry again” . After I type in (for example: A), it prints “invalid input” again even though it’s in the dictionary. I’m not sure why this happens. Could you fix this code?
grading_scale = {
"A": "90 - 100",
"A-": "88 - 89.99",
"B+": "86 - 87.99",
"B": "80 - 85.99",
"B-": "78 - 79.99",
"C+": "76 - 77.99",
"C": "70 - 75.99",
"Fail": "69.99 or less",
}
while True:
course_grade=input("What letter grade did
you get in "+course_ID +"?: ")
if course_grade not in grading_scale:
print("Invalid input, Retry again. ")
course_grade=input("What letter grade
did you get in "+course_ID +"?: ")
#add else block for the inputed
course_grade is present in dictionary
grading_scale
#if user enter correct letter grade then
break the loop
else:
break
Transcribed Image Text:grading_scale = { "A": "90 - 100", "A-": "88 - 89.99", "B+": "86 - 87.99", "B": "80 - 85.99", "B-": "78 - 79.99", "C+": "76 - 77.99", "C": "70 - 75.99", "Fail": "69.99 or less", } while True: course_grade=input("What letter grade did you get in "+course_ID +"?: ") if course_grade not in grading_scale: print("Invalid input, Retry again. ") course_grade=input("What letter grade did you get in "+course_ID +"?: ") #add else block for the inputed course_grade is present in dictionary grading_scale #if user enter correct letter grade then break the loop else: break
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Fibonacci algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT