Answer:
Following are the code to this question:
def strip_r_o(val): #Defining a method strip_r_o that takes a parameter
r = "" #defining a string variable
for x in range(len(val)): # declaring a for loop that reads input value
if (not val[x] == "R") and (not val[x] == "O"): #declaring if block to check first character is not R and O
r=r+val[x] #add character values
print(r) #Print calculated value
val= input("Enter a string: ") #input value from user end
strip_r_o(val) #Calling strip_r_o method
Output:
Enter a string: Raju
a
aj
aju
Step-by-step explanation:
Following are the description of the above python code:
- In the above code, a method "strip_r_o" is declared in which "val" variable is passed as a parameter, inside the method a string variable "r" is declared, that uses the for loop to removes "R and O" from the string value and store and print its values.
- In the next step, val variable is declared, that the input value from the user and call the "strip_r_o" method value.