Это то, что вы ищете?
def xxx():
for title in titles:
x = title.get_attribute('href')
posts_list.append(x)
# this should come out of the titles loop,
# since you were currently adding data,
# and then you can traverse through it
for p in posts_list:
# Calling your help(), assuming it does accepts p from your list
help(p)
print(len(posts_list))
# Indentation matters, please look into the Python Indentation,
# this is where you will be calling your method outside your def xxx()
xxx()
ВАША ФУНКЦИЯ ПОМОЩИ
# def help should accept an argument p, which you will use to print the data
def help(p):
print(f"this is {p}")
Надеюсь, это то, что вы ищете . Пожалуйста, изучите Python Отступ , чтобы подобрать sh свои основы Python, потому что это имеет значение при написании кода.
Спасибо и удачного обучения :)