Saturday 24 December 2022

Reading List Element Under the Condition in Python

# Reading List Element Under the Condition in Two Ways

mylist=["ABC","DEF","DEFG","ABBC"]

for i in mylist:

    if i[0:2]=="AB":

        print(i)

    if i.startswith("DE"):

        print(i)

    

No comments:

Post a Comment