Python noob here! I’m trying to replace an input string with another string, depending on which condition is met. My problem is that it only works when the first condition is met. When I run the program it prompts me for an input of A, B, C, D or E. If I enter “a” or “A” the string gets converted to “Class A”, which shows when the print statement is executed. If I enter any other option (“b” thru “e” or “B” thru “E”) the string never gets converted. My print statement prints the original input string, not the desired replacement string. Been beating my head against the keyboard for 4 hours now. What am I doing wrong?
rv_class = [“Class A”, “Class C”, “Class B/Van”, “Travel Trailer”, “5th Wheel” ]
a = rv_class[0]
b = rv_class[1]
c = rv_class[2]
t = rv_class[3]
f = rv_class[4]
rv_class[0] = “Class A”
rv_class[1] = “Class B”
rv_class[2] = “Class C”
rv_class[3] = “Travel Trailer”
rv_class[4] = “5t Wheel”
rv_type = input("Please select your RV Type: \nA) Class A \nB) Class B/Van \nC) Class C \nD) Travel Trailer \nE) 5th Wheel \n\n[A/B/C/D/E]? : ").upper()
if input == “a” or “A”:
newStr = rv_type.replace(“A”, rv_class[0])`
elif input == “b” or “B”:
newStr = rv_type.replace(“B”, rv_class[1])
elif input == “c” or “C”:
newStr = rv_type.replace(“C”, rv_class[2])
elif input == “d” or “D”:
newStr = rv_type.replace(“D”, rv_class[3])
elif input == “e” or “E”:
newStr = rv_type.replace(“E”, rv_class[4])
print("Equipment Type: ", newStr)