Q:

Write a Python program to find the items starts with specific character from a given list

0

Write a Python program to find the items starts with specific character from a given list.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def test(lst, char):
    result = [i for i in lst if i.startswith(char)]
    return result
text = ["abcd", "abc", "bcd", "bkie", "cder", "cdsw", "sdfsd", "dagfa", "acjd"]
print("\nOriginal list:")
print(text)
char = "a"
print("\nItems start with",char,"from the said list:")
print(test(text, char))
char = "d"
print("\nItems start with",char,"from the said list:")
print(test(text, char))
char = "w"
print("\nItems start with",char,"from the said list:")
print(test(text, char))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now