You need to keep things simple that way you can actually read and modify this later to build your python knowledge.

The reason this code should work when yours didn't is that you returned after every single if statement. Return statements exit the function in python so your code would only have returned your field plus a blank space if it worked at all. <> is not how you express not equals in python. In python not equals is !=.

I believe you can get away with not having a not equals operator in your function because blank and null values equate to False in python. If statements test for True so if your string isn't blank or null, it should be True and strings should be concatenated.

You can leave your fields till the end when you call the function because the things between the parenthesis in your function definition line,
def concatenate_address(address, street_name, apartment, city_code, zip_code):, are called parameters. Python uses these parameters to know what to do with your arguments, which would be what you pass to them when you call the function. When you pass in your actual fields, python replaces the parameters with those fields, your arguments, when it runs your function.

Please leave a comment on my answer if you have any questions and I will get back to you. Also, try to adopt my formatting. It's the proper way to right python and extremely readable. You will thank me in 6 months when you're looking at this again and have no idea what you wrote.

Filter will keep items from the list which are logically True. Empty strings (and None) values are logically False, so the lambda simply returns a stripped string value. Again, you can call this with the Python parser.