GH Python - very basic query

Hello everyone,
I am trying to learn Python and use it in GH.
This is my very first attempt, so I beg your pardon beforehand.
Thanks so much

I am trying to check a list of strings, if they contain “RC”, I leave it as it is, if not, I want to replace " " with “” (as in remove spaces) and replace “.0” with “” (as in remove “.0” from the string). The desired output will be the updated list of strings.
The input is set to List access.

import rhinoscriptsyntax as rs
# Initialize an empty list to store the output
output_list = [ ]

 # Iterate through each item in the input list
for item in input_list:
    # Check if the item contains "RC"
    if "RC" in item:
        # If it does, add it to the output list as is
        # If not, remove spaces and ".0" and add to the output list
        cleaned_item = item.replace(" ", "").replace(".0", "")

# Output the updated list of strings
output = output_list

The code is correct AFAICS. Well done. You can make it really short and elegant using a list comprehension and a ternary operator (an if else expression) by the way.

You just need to get the output from output_list into a variable, that the GhPython component will send back to Grasshopper - a common default name is a.

The ‘output’ output variable is special, it contains the output (as you’d expect) from all the print statements, and any error messages.

Many thanks!!