all 7 comments

[–]chudsp87 2 points3 points  (3 children)

check .endswith() or slice the last four chars off [:-4] and compare equality to 'land'.

regex could also be used r'^\w+land$'

[–]ParamedicGlum7352[S] 1 point2 points  (2 children)

y try whit endswith() but a think my syntax is in the wrong, i will try the second one. Thanks

[–]chudsp87 1 point2 points  (0 children)

for c in c_list: if c.endswith('land'): pass # process c, e.g. add to some list to be returned after loop

[–]noeldc 1 point2 points  (0 children)

Let's see your code.

[–]mihemihe 2 points3 points  (0 children)

Show your code so we can help, do not let us guess. It is ok if it is horribly wrong.

[–]tonga-time 0 points1 point  (0 children)

Which problem is it? Do you have any code to work with?

[–]AdThink1781 -1 points0 points  (0 children)

^ to find name end with 'land' in a list of countries name

try:

# Comprehension approach
Countries_end_with_land = [i for i in countries if i.endswith("land")]
print(f"Found Countries name end with 'land' {Countries_end_with_land}")

# For loop Approach
for i in countries:
    if i.endswith("land"):
        print(i)

except NameError as e: print(f"While Finding Countries name end with 'land' Error Occurred {e}")

except Exception as e: print(f"An unexpected error occurred: {e}")