Review the code snippet below: maritalStatus = input(\"Enter your marital status
ID: 3930367 • Letter: R
Question
Review the code snippet below:
maritalStatus = input("Enter your marital status (s for single, m for married): ")
maritalStatus = maritalStatus.upper()
Which of the following statements can be used to validate whether the user entered a valid marital status?Question 3 options:
A)
if maritalStatus == "S" or maritalStatus == "M" :
B)
if maritalStatus == "s" or maritalStatus == "m" :
C)
if (maritalStatus == "s" or maritalStatus == "m") and
(maritalStatus == "S" or maritalStatus == "M") :
D)
if maritalStatus == "s" or "S" or "m" or "M" :
Explanation / Answer
A)
#get the input from user.
maritalStatus = input("Enter your marital status (s for single, m for married): ")
#convert the input to upper case.
maritalStatus = maritalStatus.upper()
# it would be enough to check in the upper case letters
# whether an input is valid or not.
if martialStatus == "S" or matrialStatus == "M":
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.